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

Delyan Angelov 2022-06-03 19:14:01 +03:00 committed by Chewing_Bever
parent b387554840
commit 3e1ff72247
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
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 { '' }
modifier := if field.is_volatile { ' volatile ' } else { '' }
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 g.pref.translated {
g.definitions.write_string(' = ${g.expr_string(field.expr)}')