From 8d7e628878aac07d0380463196f823502d1816ce Mon Sep 17 00:00:00 2001 From: Zuhaitz Méndez Fernández de Aránguiz Date: Tue, 13 Jan 2026 12:58:55 +0000 Subject: Fix for #10 --- src/codegen/codegen_decl.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/codegen/codegen_decl.c') diff --git a/src/codegen/codegen_decl.c b/src/codegen/codegen_decl.c index ac4ae14..4979236 100644 --- a/src/codegen/codegen_decl.c +++ b/src/codegen/codegen_decl.c @@ -8,7 +8,7 @@ #include // Emit C preamble with standard includes and type definitions. -void emit_preamble(FILE *out) +void emit_preamble(ParserContext *ctx, FILE *out) { if (g_config.is_freestanding) { @@ -54,8 +54,11 @@ void emit_preamble(FILE *out) fputs("#include \n#include \n", out); // POSIX functions fputs("#ifdef __TINYC__\n#define __auto_type __typeof__\n#endif\n", out); fputs("typedef size_t usize;\ntypedef char* string;\n", out); - fputs("#include \n", out); - fputs("typedef struct { pthread_t thread; void *result; } Async;\n", out); + if (ctx->has_async) + { + fputs("#include \n", out); + fputs("typedef struct { pthread_t thread; void *result; } Async;\n", out); + } fputs("typedef struct { void *func; void *ctx; } z_closure_T;\n", out); fputs("#define U0 void\n#define I8 int8_t\n#define U8 uint8_t\n#define I16 " "int16_t\n#define U16 uint16_t\n", -- cgit v1.2.3