1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

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

This commit is contained in:
Delyan Angelov 2022-06-03 19:14:01 +03:00
parent dbaecdc058
commit 6f9070e06d

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)}')