mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
@sprintf macro (based on the $$sprintf builtin) allows compile time format strings #1874.
This commit is contained in:
14
test/test_suite/compile_time/ct_sprintf.c3t
Normal file
14
test/test_suite/compile_time/ct_sprintf.c3t
Normal file
@@ -0,0 +1,14 @@
|
||||
// #target: macos-x64
|
||||
module test;
|
||||
fn void main()
|
||||
{
|
||||
var $foo = "hello";
|
||||
var $c = { 1, 3 };
|
||||
String x = $$sprintf("%s %s", $foo, $c);
|
||||
String y = @sprintf("%s %s", $c, $foo);
|
||||
}
|
||||
|
||||
/* #expect: test.ll
|
||||
|
||||
@.str = private unnamed_addr constant [13 x i8] c"hello {1, 3}\00", align 1
|
||||
@.str.1 = private unnamed_addr constant [13 x i8] c"{1, 3} hello\00", align 1
|
||||
Reference in New Issue
Block a user