I'm in the process of porting some code from the GIMP source code base into a program I am writing. Part of the code (/gimp-2.8.10//modules/display-filter-color-blind.c) references a macro called GIMP_CAIRO_ARGB32_SET_PIXEL (gimp-2.8.10//libgimpcolor/gimpcairocolor.h). Within that macro there is something called G_STMT_START/G_STMT_END. My compiler (Mac OSX via Xcode with the default compiler) is complaining with the error "Use of undeclared identifier 'G_STMT_START'" I know it is not a scoping issue with where I put the macros (in a header file called globals.h that I include in my .h) because the compiler is not complaining about the GIMP_CAIRO_ARGB32_SET_PIXEL define.
Does anyone know whats going on here? I've attempted to grep through all instances of G_STMT_START in the GIMP source but have not found anything that seems to define G_STMT_START/G_STMT_END. I also found sort of an explanation in the GIMP toolkit documentation, but it's far from helpful (for me at least).
This is the full macro that I am trying to use:
/**
* GIMP_CAIRO_ARGB32_SET_PIXEL:
* @d: pointer to the destination buffer
* @r: red component, not pre-multiplied
* @g: green component, not pre-multiplied
* @b: blue component, not pre-multiplied
* @a: alpha component
*
* Sets a single pixel in an Cairo image surface in %CAIRO_FORMAT_ARGB32.
*
* Since: GIMP 2.6
**/
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define GIMP_CAIRO_ARGB32_SET_PIXEL(d, r, g, b, a) \
G_STMT_START { \
const guint tr = (a) * (r) + 0x80; \
const guint tg = (a) * (g) + 0x80; \
const guint tb = (a) * (b) + 0x80; \
(d)[0] = (((tb) >> 8) + (tb)) >> 8; \
(d)[1] = (((tg) >> 8) + (tg)) >> 8; \
(d)[2] = (((tr) >> 8) + (tr)) >> 8; \
(d)[3] = (a); \
} G_STMT_END
#else
#define GIMP_CAIRO_ARGB32_SET_PIXEL(d, r, g, b, a) \
G_STMT_START { \
const guint tr = (a) * (r) + 0x80; \
const guint tg = (a) * (g) + 0x80; \
const guint tb = (a) * (b) + 0x80; \
(d)[0] = (a); \
(d)[1] = (((tr) >> 8) + (tr)) >> 8; \
(d)[2] = (((tg) >> 8) + (tg)) >> 8; \
(d)[3] = (((tb) >> 8) + (tb)) >> 8; \
} G_STMT_END
#endif
Thanks for any help with this!