diff options
Diffstat (limited to 'source/20-codegen-compiler/CodegenMacros.hpp')
-rw-r--r-- | source/20-codegen-compiler/CodegenMacros.hpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/source/20-codegen-compiler/CodegenMacros.hpp b/source/20-codegen-compiler/CodegenMacros.hpp index 84c9d09..e56aed0 100644 --- a/source/20-codegen-compiler/CodegenMacros.hpp +++ b/source/20-codegen-compiler/CodegenMacros.hpp @@ -5,7 +5,12 @@ // I give up, hopefully nothing overflows this buffer // TODO handle buffer sizing properly -#define APPEND_LIT(out, str) out += str +#define INPLACE_FMT(varName, format, ...) \ + char varName[2048]; \ + snprintf(varName, sizeof(varName), format, __VA_ARGS__); + +#define APPEND_LIT(out, str) \ + out += str #define APPEND_FMT(out, format, ...) \ { \ @@ -14,7 +19,8 @@ out += buffer; \ } -#define WRITE_LIT(file, str) fwrite(str, sizeof(char), sizeof(str) - 1, file) +#define WRITE_LIT(file, str) \ + fwrite(str, sizeof(char), sizeof(str) - 1, file) // NOTE: snprintf() returns the size written (given an infinite buffer) not including \0 #define WRITE_FMT(file, format, ...) \ |