]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Include glib-object.h for Structs with type_id
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 16 Aug 2017 07:36:52 +0000 (09:36 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 16 Aug 2017 07:59:02 +0000 (09:59 +0200)
codegen/valaccodestructmodule.vala
tests/Makefile.am
tests/structs/struct_only.vala [new file with mode: 0644]

index 7d58aeb30b08d0154d0243b90ea157522b6acd50..eb52d472ec6586c0503bba7eaf691e4799691979 100644 (file)
@@ -54,6 +54,7 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
                }
 
                if (get_ccode_has_type_id (st)) {
+                       decl_space.add_include ("glib-object.h");
                        decl_space.add_type_declaration (new CCodeNewline ());
                        var macro = "(%s_get_type ())".printf (get_ccode_lower_case_name (st, null));
                        decl_space.add_type_declaration (new CCodeMacroReplacement (get_ccode_type_id (st), macro));
index 910cfb6faddc1e83880be8f96abfb2b7786649e6..5518b2d120df32a5ee75098f0ae03509495c42ed 100644 (file)
@@ -93,6 +93,7 @@ TESTS = \
        enums/bug673879.vala \
        enums/bug763831.vala \
        enums/bug780050.vala \
+       structs/struct_only.vala \
        structs/structs.vala \
        structs/gvalue.vala \
        structs/bug530605.vala \
diff --git a/tests/structs/struct_only.vala b/tests/structs/struct_only.vala
new file mode 100644 (file)
index 0000000..5d60a04
--- /dev/null
@@ -0,0 +1,6 @@
+public struct Foo {
+       public int i;
+}
+
+void main () {
+}