mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-07 14:24:43 +00:00
force comptime on comptimePrint
This commit is contained in:
parent
3811602ad7
commit
548fd6e87b
1 changed files with 6 additions and 4 deletions
|
|
@ -1182,11 +1182,13 @@ fn bufPrintIntToSlice(buf: []u8, value: anytype, base: u8, uppercase: bool, opti
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn comptimePrint(comptime fmt: []const u8, args: anytype) *const [count(fmt, args):0]u8 {
|
pub fn comptimePrint(comptime fmt: []const u8, args: anytype) *const [count(fmt, args):0]u8 {
|
||||||
comptime var buf: [count(fmt, args):0]u8 = undefined;
|
comptime {
|
||||||
|
var buf: [count(fmt, args):0]u8 = undefined;
|
||||||
_ = bufPrint(&buf, fmt, args) catch unreachable;
|
_ = bufPrint(&buf, fmt, args) catch unreachable;
|
||||||
buf[buf.len] = 0;
|
buf[buf.len] = 0;
|
||||||
return &buf;
|
return &buf;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
test "comptimePrint" {
|
test "comptimePrint" {
|
||||||
@setEvalBranchQuota(2000);
|
@setEvalBranchQuota(2000);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue