diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-03-03 15:14:59 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-03-03 15:14:59 -0500 |
| commit | 2a7cfd7c3665c441c25094c12bde02ddc565061c (patch) | |
| tree | 38e670a74d5551c5345fa31e27c62f4f81188003 | |
| parent | 00e7ce2bd089ed8180d8e819b8260a3ba9eb13f1 (diff) | |
Fix table literal issue for TCC compatibility
| -rw-r--r-- | builtins/table.h | 3 | ||||
| -rw-r--r-- | compile.c | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/builtins/table.h b/builtins/table.h index 14a97977..436eaf42 100644 --- a/builtins/table.h +++ b/builtins/table.h @@ -8,7 +8,8 @@ #include "array.h" #define $Table(key_t, val_t, key_info, value_info, fb, def, ...) ({ \ - struct { key_t k; val_t v; } $ents[] = {__VA_ARGS__}; \ + struct $entry_s { key_t k; val_t v; }; \ + struct $entry_s $ents[] = {__VA_ARGS__}; \ table_t $table = Table_from_entries((array_t){ \ .data=memcpy(GC_MALLOC(sizeof($ents)), $ents, sizeof($ents)), \ .length=sizeof($ents)/sizeof($ents[0]), \ @@ -567,7 +567,7 @@ CORD compile(env_t *env, ast_t *ast) for (ast_list_t *entry = table->entries; entry; entry = entry->next) { auto e = Match(entry->ast, TableEntry); - code = CORD_all(code, ",\n\t{", compile(env, e->key), ", ", compile(env, e->value), "}"); + code = CORD_all(code, ",\n\t(struct $entry_s){", compile(env, e->key), ", ", compile(env, e->value), "}"); } return CORD_cat(code, ")"); |
