diff --git a/compiler/cheaders.v b/compiler/cheaders.v index b2c935c888..3dc700699b 100644 --- a/compiler/cheaders.v +++ b/compiler/cheaders.v @@ -55,7 +55,7 @@ CommonCHeaders = ' // MSVC cannot parse some things properly #undef EMPTY_STRUCT_DECLARATION -#define EMPTY_STRUCT_DECLARATION void *____dummy_variable; +#define EMPTY_STRUCT_DECLARATION void *____dummy_variable #undef OPTION_CAST #define OPTION_CAST(x) #endif diff --git a/compiler/parser.v b/compiler/parser.v index e874fb9b52..e662e1634d 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -637,6 +637,7 @@ fn (p mut Parser) struct_decl() { if attr == 'raw' && field_type != 'string' { p.error('struct field with attribute "raw" should be of type "string" but got "$field_type"') } + did_gen_something = true if p.first_pass() { p.table.add_field(typ.name, field_name, field_type, is_mut, attr, access_mod) @@ -644,6 +645,13 @@ fn (p mut Parser) struct_decl() { p.fgenln('') } p.check(.rcbr) + if !is_c { + if !did_gen_something { + if p.first_pass() { + p.table.add_field(typ.name, '', 'EMPTY_STRUCT_DECLARATION', false, '', .private) + } + } + } p.fgenln('\n') }