summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2017-08-16 09:36:52 +0200
committerRico Tzschichholz <ricotz@ubuntu.com>2017-08-16 09:45:34 +0200
commit318f378f7ab894ea29f4e0e2d5639f5a9601f79b (patch)
tree111a0ae0be39d47ddb7c80f3473fc217027b0bba
parent2bac070afdc070e1dcbdc5b4bf7589293a8fdb86 (diff)
downloadvala-318f378f7ab894ea29f4e0e2d5639f5a9601f79b.tar.gz
codegen: Include glib-object.h for Structs with type_id
-rw-r--r--codegen/valaccodestructmodule.vala1
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/structs/struct_only.vala6
3 files changed, 8 insertions, 0 deletions
diff --git a/codegen/valaccodestructmodule.vala b/codegen/valaccodestructmodule.vala
index 9457b3556..9774570cd 100644
--- a/codegen/valaccodestructmodule.vala
+++ b/codegen/valaccodestructmodule.vala
@@ -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));
diff --git a/tests/Makefile.am b/tests/Makefile.am
index bbaa74aec..9baab1c91 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -116,6 +116,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
index 000000000..5d60a04f1
--- /dev/null
+++ b/tests/structs/struct_only.vala
@@ -0,0 +1,6 @@
+public struct Foo {
+ public int i;
+}
+
+void main () {
+}