Can I make this change (enum macros colliding with guile macros)

Geert Janssens janssens-geert at telenet.be
Wed Jun 2 10:53:26 EDT 2010


On Wednesday 2 June 2010, Christian Stimming wrote:
> Zitat von Geert Janssens <janssens-geert at telenet.be>:
> > Most of these are easily solved. But I hit this one now and I'm not sure
> > how to proceed.
> >
> > src/gnome/dialog-print-check.c contains this construct:
> > #define ENUM_CHECK_ITEM_TYPE(_) \
> >         _(NONE,) \
> >         _(PAYEE,) \
> 
> This is a real brainf'kd construct. Something like simulating
> templates but in C but with macros, even though macros are evil. It is
> defined in src/libqof/qof/qofutils.h and might seem so insanely smart
> at first sight, but due to the inherent evil of macros it won't work
> on a larger scale, as you have just encountered. (Note to self: Gosh,
> I really hate C today.)
> 
> No, the _() is not the usual gettext macro here but instead it's the
> local name of the macro's argument. It
> 
> > Can anyone explain to me how to interpret this construct ? And even more
> > importantly, if I can add the CHK_ prefix without unintended side-effects
> > ?
> 
> Unfortunately no because the identifiers are used both as enum values
> and as their string representations and e.g. dialog-print-check.c line
> 942 relies on this conversion from the string representation to the
> enum value.
Thanks for the explanation. So if I get this right, I could change the enum 
values if I also changed ALL uses of the enum names as strings. I found these 
strings in the checks definitions.

> 
> But couldn't the compiler error be fixed by #undef'ing DATE *before*
> these lines in dialog-print-check.c?
> 
I didn't think of this. I'll try it that way. Seems a much easier solution.

Thank you !

Geert


More information about the gnucash-devel mailing list