]> 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>
Sat, 8 Dec 2018 09:48:58 +0000 (10:48 +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 c4d00aba565c18589978c9773b4d45146d9c9e9f..9012567c4d00f459789245d871ac84b45a5002e3 100644 (file)
@@ -644,6 +644,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 (",")) {