From: Jürg Billeter Date: Tue, 16 Feb 2010 15:41:30 +0000 (+0100) Subject: Fix public struct constants X-Git-Tag: 0.8.0~262 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7417da939643f682b6628e6fe93d91f8094f016c;p=thirdparty%2Fvala.git Fix public struct constants Fixes bug 610067. --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index 458f3e31c..287e494c7 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -910,8 +910,20 @@ internal class Vala.CCodeBaseModule : CCodeModule { if (c.type_reference is ArrayType) { arr = "[]"; } - cdecl.add_declarator (new CCodeVariableDeclarator ("%s%s".printf (c.get_cname (), arr), (CCodeExpression) c.initializer.ccodenode)); - cdecl.modifiers = CCodeModifiers.STATIC; + + var cinitializer = (CCodeExpression) c.initializer.ccodenode; + if (decl_space != source_declarations) { + // never output value in header + // special case needed as this method combines declaration and definition + cinitializer = null; + } + + cdecl.add_declarator (new CCodeVariableDeclarator ("%s%s".printf (c.get_cname (), arr), cinitializer)); + if (c.is_private_symbol ()) { + cdecl.modifiers = CCodeModifiers.STATIC; + } else { + cdecl.modifiers = CCodeModifiers.EXTERN; + } decl_space.add_constant_declaration (cdecl); } else {