cgen: do not initialise externally declared globals (with -cstrict with [c_extern]).

master
Delyan Angelov 2022-06-03 19:14:01 +03:00
parent dbaecdc058
commit 6f9070e06d
1 changed files with 4 additions and 0 deletions

View File

@ -4660,6 +4660,10 @@ fn (mut g Gen) global_decl(node ast.GlobalDecl) {
extern := if cextern { 'extern ' } else { '' } extern := if cextern { 'extern ' } else { '' }
modifier := if field.is_volatile { ' volatile ' } else { '' } modifier := if field.is_volatile { ' volatile ' } else { '' }
g.definitions.write_string('$extern$visibility_kw$modifier$styp $attributes $field.name') g.definitions.write_string('$extern$visibility_kw$modifier$styp $attributes $field.name')
if cextern {
g.definitions.writeln('; // global5')
continue
}
if field.has_expr || cinit { if field.has_expr || cinit {
if g.pref.translated { if g.pref.translated {
g.definitions.write_string(' = ${g.expr_string(field.expr)}') g.definitions.write_string(' = ${g.expr_string(field.expr)}')