summaryrefslogtreecommitdiff
path: root/src/codegen/codegen_decl.c
diff options
context:
space:
mode:
authorZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-26 00:55:08 +0000
committerZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-26 00:55:08 +0000
commit4a20a08c80d1170561db9a268e8116ad311714b9 (patch)
tree093344f67a28d86809de89eda8b067f17665844a /src/codegen/codegen_decl.c
parentca08979910e5a234a2423e4448ad0e284bf4f508 (diff)
Fix for #126
Diffstat (limited to 'src/codegen/codegen_decl.c')
-rw-r--r--src/codegen/codegen_decl.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/codegen/codegen_decl.c b/src/codegen/codegen_decl.c
index e5d73a0..d59511d 100644
--- a/src/codegen/codegen_decl.c
+++ b/src/codegen/codegen_decl.c
@@ -22,7 +22,8 @@ static void emit_freestanding_preamble(FILE *out)
"uint64_t\n",
out);
fputs("#define F32 float\n#define F64 double\n", out);
- fputs("static inline const char* _z_bool_str(_Bool b) { return b ? \"true\" : \"false\"; }\n", out);
+ fputs("static inline const char* _z_bool_str(_Bool b) { return b ? \"true\" : \"false\"; }\n",
+ out);
fputs("#define _z_str(x) _Generic((x), _Bool: \"%s\", char: \"%c\", "
"signed char: \"%c\", unsigned char: \"%u\", short: \"%d\", "
"unsigned short: \"%u\", int: \"%d\", unsigned int: \"%u\", "
@@ -64,9 +65,11 @@ void emit_preamble(ParserContext *ctx, FILE *out)
fputs("#define ZC_AUTO auto\n", out);
fputs("#define ZC_CAST(T, x) static_cast<T>(x)\n", out);
// C++ _z_str via overloads
- fputs("inline const char* _z_bool_str(bool b) { return b ? \"true\" : \"false\"; }\n", out);
+ fputs("inline const char* _z_bool_str(bool b) { return b ? \"true\" : \"false\"; }\n",
+ out);
fputs("inline const char* _z_str(bool) { return \"%s\"; }\n", out);
- fputs("inline const char* _z_arg(bool b) { return _z_bool_str(b); }\n", out);
+ fputs("inline const char* _z_arg(bool b) { return _z_bool_str(b); }\n",
+ out);
fputs("template<typename T> inline T _z_arg(T x) { return x; }\n", out);
fputs("inline const char* _z_str(char) { return \"%c\"; }\n", out);
fputs("inline const char* _z_str(int) { return \"%d\"; }\n", out);
@@ -87,7 +90,9 @@ void emit_preamble(ParserContext *ctx, FILE *out)
fputs("#define ZC_AUTO __auto_type\n", out);
fputs("#define ZC_CAST(T, x) ((T)(x))\n", out);
fputs("#ifdef __TINYC__\n#define __auto_type __typeof__\n#endif\n", out);
- fputs("static inline const char* _z_bool_str(_Bool b) { return b ? \"true\" : \"false\"; }\n", out);
+ fputs("static inline const char* _z_bool_str(_Bool b) { return b ? \"true\" : "
+ "\"false\"; }\n",
+ out);
fputs("#define _z_str(x) _Generic((x), _Bool: \"%s\", char: \"%c\", "
"signed char: \"%c\", unsigned char: \"%u\", short: \"%d\", "
"unsigned short: \"%u\", int: \"%d\", unsigned int: \"%u\", "