]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Always emit constants with initializer-list
authorRico Tzschichholz <ricotz@ubuntu.com>
Sat, 8 Dec 2018 09:41:50 +0000 (10:41 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 18 Dec 2018 08:06:02 +0000 (09:06 +0100)
generate_constant_declaration() handles both definition and declaration.

This is important when using --use-header where the actual definition
would never be written and we ended up with an "extern const ..." in the
header only.

Fixes https://gitlab.gnome.org/GNOME/vala/issues/81

codegen/valaccodebasemodule.vala

index 14c9286d57b203ec627875a3a91cdf9c0b9c9045..b7a8e94d3dbea2567f24d12f5f8ad7275fc9fa07 100644 (file)
@@ -629,6 +629,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                if (sym.anonymous) {
                        return !decl_space.is_header && CodeContext.get ().use_header;
                }
+               // constants with initializer-list are special
+               if (sym is Constant && ((Constant) sym).value is InitializerList) {
+                       return false;
+               }
                if (sym.external_package || (!decl_space.is_header && CodeContext.get ().use_header && !sym.is_internal_symbol ())) {
                        // add feature test macros
                        foreach (unowned string feature_test_macro in get_ccode_feature_test_macros (sym).split (",")) {