After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 667186 - typedef placement affects generated gir
typedef placement affects generated gir
Status: RESOLVED DUPLICATE of bug 581525
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2012-01-03 15:00 UTC by mbooth
Modified: 2015-02-07 17:00 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description mbooth 2012-01-03 15:00:24 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.
Comment 1 Evan Nemerson 2012-05-04 06:28:07 UTC
I think this is duplicate of #581525
Comment 2 Simon Feltman 2014-08-19 19:33:44 UTC
(bug 581525 is fixed)

*** This bug has been marked as a duplicate of bug 581525 ***
Comment 3 André Klapper 2015-02-07 17:00:17 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]