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 688356 - typedef + define = bad gir
typedef + define = bad gir
Status: RESOLVED FIXED
Product: gobject-introspection
Classification: Platform
Component: general
2.35.x
Other Mac OS
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2012-11-15 01:00 UTC by John Ralls
Modified: 2015-02-07 17:01 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description John Ralls 2012-11-15 01:00:41 UTC
The following, fairly common, C idiom

  typedef guint32 PangoGlyph;

  #define PANGO_GLYPH_EMPTY  ((PangoGlyph)0xfffffffff)

Produces this in the .gir:
 
    <constant name="GLYPH_EMPTY" value="268435455" c:type="PANGO_GLYPH_EMPTY">
      <type c:type="PangoGlyph"/>
    </constant>

Which then fails in gir-compile with 
  Pango-1.0.gir:40:34: error: Line 40, character 34: The attribute 'name' on
     the  element 'type' must be specified
  error parsing file Pango-1.0.gir: Line 40, character 34: The attribute 'name'
     on the element 'type' must be specified

I attempted to coerce the type back to guint32 with a (type) annotation on PANGO_GLYPH_EMPTY, but it was ignored.

One can work around the problem by converting the define to an enum:

enum
  {
     PANGO_GLYPH_EMPTY = ((PangoGlyph)0xffffffff)
  };

but ISTM g-i should handle the define case as well.
Comment 1 Marc-Antoine Perennou 2012-12-29 14:15:57 UTC
With latest release of gobject-introspection, this seems to be fixed:

    <constant name="GLYPH_EMPTY" value="268435455" c:type="PANGO_GLYPH_EMPTY">
      <type name="Glyph" c:type="PangoGlyph"/>
    </constant>

Maybe we could revert http://git.gnome.org/browse/pango/commit/pango/pango-font.h?id=7274bd56db3ce2f02594687a307d22aa99c787c4 and depend on a newer version of g-i ? (this said commit causes warnings to be emitted when compiling client gtk code with -pedantic: /usr/include/pango-1.0/pango/pango-font.h:380:33: warning: ISO C restricts enumerator values to range of ‘int’ [-pedantic])
Comment 2 John Ralls 2012-12-29 21:39:46 UTC
Reverted.

Indeed, I couldn't get the bug to replicate even with earlier versions of g-ir-scanner, so I've no idea at this point what was going wrong.
Comment 3 André Klapper 2015-02-07 17:01:39 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]