From 3ee57d065fa8d80ae1ca1cfa179c33a7cddc24d5 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Mon, 30 Sep 2024 08:19:23 -0300 Subject: [PATCH] fix --- vlib/v/gen/c/cgen.v | 3 +-- ...c.must_have => global_initializer_nix.c.must_have} | 0 ...lobal_initializer.vv => global_initializer_nix.vv} | 0 .../c/testdata/global_initializer_windows.must_have | 1 + vlib/v/gen/c/testdata/global_initializer_windows.vv | 11 +++++++++++ 5 files changed, 13 insertions(+), 2 deletions(-) rename vlib/v/gen/c/testdata/{global_initializer.c.must_have => global_initializer_nix.c.must_have} (100%) rename vlib/v/gen/c/testdata/{global_initializer.vv => global_initializer_nix.vv} (100%) create mode 100644 vlib/v/gen/c/testdata/global_initializer_windows.must_have create mode 100644 vlib/v/gen/c/testdata/global_initializer_windows.vv diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 20b2fe40c9aae0..2ffa2beaafa58e 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -7353,8 +7353,7 @@ fn (mut g Gen) type_default(typ_ ast.Type) string { '{' } $if windows { - if g.pref.ccompiler_type == .tinyc && !typ.has_flag(.shared_f) - && g.inside_global_decl { + if !typ.has_flag(.shared_f) && g.inside_global_decl { init_str = '(${g.typ(typ)}){' } } diff --git a/vlib/v/gen/c/testdata/global_initializer.c.must_have b/vlib/v/gen/c/testdata/global_initializer_nix.c.must_have similarity index 100% rename from vlib/v/gen/c/testdata/global_initializer.c.must_have rename to vlib/v/gen/c/testdata/global_initializer_nix.c.must_have diff --git a/vlib/v/gen/c/testdata/global_initializer.vv b/vlib/v/gen/c/testdata/global_initializer_nix.vv similarity index 100% rename from vlib/v/gen/c/testdata/global_initializer.vv rename to vlib/v/gen/c/testdata/global_initializer_nix.vv diff --git a/vlib/v/gen/c/testdata/global_initializer_windows.must_have b/vlib/v/gen/c/testdata/global_initializer_windows.must_have new file mode 100644 index 00000000000000..383d042d59b133 --- /dev/null +++ b/vlib/v/gen/c/testdata/global_initializer_windows.must_have @@ -0,0 +1 @@ +Array_fixed_main__Foo_3 g_test_foo = {(main__Foo){.foo = 0,.bar = (main___VAnonStruct1){.a = 0,.b = 0,},}, (main__Foo){.foo = 0,.bar = (main___VAnonStruct1){.a = 0,.b = 0,},}, (main__Foo){.foo = 0,.bar = (main___VAnonStruct1){.a = 0,.b = 0,},}}; // global4 \ No newline at end of file diff --git a/vlib/v/gen/c/testdata/global_initializer_windows.vv b/vlib/v/gen/c/testdata/global_initializer_windows.vv new file mode 100644 index 00000000000000..6f2ad48dc3a8bb --- /dev/null +++ b/vlib/v/gen/c/testdata/global_initializer_windows.vv @@ -0,0 +1,11 @@ +// vtest vflags: -enable-globals + +struct Foo { + foo int + bar struct { + a int + b f64 + } +} + +__global g_test_foo = [3]Foo{}