#how to format c strings

1 messages · Page 1 of 1 (latest)

digital copper
#

Hi, I am trying to print a sdl error with:

std.debug.panic("Could not init SDL: {}", .{sdl.SDL_GetError()});

But the compiler complains with this msg:

@compileError("cannot format pointer without a specifier (i.e. {s} or {*})");
SDL_GetError() -> [*c]const u8
wispy aspen
#

[*c]const u8 is a c "string" type, so it needs "Could not init SDL: {s}" to print properly, using {*} would print the address instead of interpreting it as a string

#

it wants you to choose one of the options ({s} or {*}) instead of assuming what you want

digital copper
#

Ah thanks, I thought I had to do something like this *.{c_string}