You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// auto-convert strings and char slices into char* when passing to va_args
)
Of course this kinda defeats the purpose, since slices are not necessarily null-terminated. The proposed alternative (which I'm proposing now) is to pass the entire struct to printf, which will cause it to get both the length and the pointer.
(aside: the layout of str is like this: struct str { len: i64; ptr: &i8 })
Then, we would need to call printf with %.*s instead of just %s.
The text was updated successfully, but these errors were encountered:
Currently the compiler automatically converts a
str
to its pointer when passing it to a C-style vararg function (eg.printf
) (seeflax/source/codegen/call.cpp
Line 193 in 8402c46
Of course this kinda defeats the purpose, since slices are not necessarily null-terminated. The proposed alternative (which I'm proposing now) is to pass the entire struct to
printf
, which will cause it to get both the length and the pointer.(aside: the layout of
str
is like this:struct str { len: i64; ptr: &i8 }
)Then, we would need to call
printf
with%.*s
instead of just%s
.The text was updated successfully, but these errors were encountered: