GNOME Bugzilla – Bug 667186
typedef placement affects generated gir
Last modified: 2015-02-07 17:00:17 UTC
I had the following in a header: === struct _GuestfsVersion { gint64 major; gint64 minor; gint64 release; gchar *extra; }; typedef struct _GuestfsVersion GuestfsVersion; GType guestfs_version_get_type(void); === which generated the following in the .gir: === <glib:boxed glib:name="Version" c:symbol-prefix="version" glib:type-name="GuestfsVersion" glib:get-type="guestfs_version_get_type"> </glib:boxed> <record name="_Version" c:type="_GuestfsVersion"> <field name="major" writable="1"> <type name="gint64" c:type="gint64"/> </field> <field name="minor" writable="1"> <type name="gint64" c:type="gint64"/> </field> <field name="release" writable="1"> <type name="gint64" c:type="gint64"/> </field> <field name="extra" writable="1"> <type name="utf8" c:type="gchar*"/> </field> </record> === This does not allow introspected access to the fields of Version. I altered the header by moving the typedef before the struct declaration: === typedef struct _GuestfsVersion GuestfsVersion; struct _GuestfsVersion { gint64 major; gint64 minor; gint64 release; gchar *extra; }; GType guestfs_version_get_type(void); === This results in the following, correct output in the .gir: === <record name="Version" c:type="GuestfsVersion" glib:type-name="GuestfsVersion" glib:get-type="guestfs_version_get_type" c:symbol-prefix="version"> <field name="major" writable="1"> <type name="gint64" c:type="gint64"/> </field> <field name="minor" writable="1"> <type name="gint64" c:type="gint64"/> </field> <field name="release" writable="1"> <type name="gint64" c:type="gint64"/> </field> <field name="extra" writable="1"> <type name="utf8" c:type="gchar*"/> </field> </record> === The above C is semantically equivalent, and the g-ir-scanner behaviour should be identical in both cases.
I think this is duplicate of #581525
(bug 581525 is fixed) *** This bug has been marked as a duplicate of bug 581525 ***
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]