From 3e1ff722476bace6702a783b440f03d086af26a3 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Fri, 3 Jun 2022 19:14:01 +0300 Subject: [PATCH] cgen: do not initialise externally declared globals (with -cstrict with [c_extern]). --- vlib/v/gen/c/cgen.v | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 2beaa1d251..fff9170f6a 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -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)}')