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

Christian Stimming stimming at tuhh.de
Wed Jun 2 10:36:55 EDT 2010


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.

But couldn't the compiler error be fixed by #undef'ing DATE *before*  
these lines in dialog-print-check.c?

Regards,

Christian



More information about the gnucash-devel mailing list