#format string fails to recognize my args as strings

1 messages · Page 1 of 1 (latest)

sinful breach
#
    const version_data = b.fmt(
        \\ #include "Version.hpp"
        \\ namespace Project {
        \\ char const* const VersionString = "0.0.1";
        \\ char const* const SourceIdentifierString = "debug";
        \\ char const* const ArchitectureString = "{s} {s}";
    , .{
        @tagName(target.result.os.tag),
        @tagName(target.result.cpu.arch),
    });

This code fails to compile with the following error:

/<zig>/lib/std/fmt.zig:492:5: error: invalid format string '
                                                               char const* const VersionString = "0.0.1";
                                                               char const* const SourceIdentifierString = "debug";
                                                               char const* const ArchitectureString = "{s' for type 'u8'
    @compileError("invalid format string '" ++ fmt ++ "' for type '" ++ @typeName(@TypeOf(value)) ++ "'");

It reads to me like the compiler is treating @tagName output as u8 instead of [:0] const u8. This also happens with string literals.

twin temple
#

i believe its treating the opening brace after namespace Project as a format specifier, do {{

sinful breach
#

oh, so i'd need to escape those