| Re: [AD] trying to make allegro compatible with MFC |
[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]
In reply to Eric Botcazou <ebotcazou@xxxxxxxxxx>:
>It looks like the two preprocessors don't behave the same.
>Is there any specialist of preprocessors here ?
Whilst I can't speak for the MS compiler, I can speak for the C
preprocessor used in gcc:
1/. The code fragment:
#define WINDOWS_RGB RGB
#undef RGB
WINDOWS_RGB(a, b, c)
will expand to `RGB(a, b, c)' (ref. 1), regardless of what RGB was
defined to be originally. So a #define line behaves as if no macros
were defined.
2/. The code fragment:
#define RGB(a, b, c) /* some function of (a, b, c) */
#define RGB struct allegro_rgb
would define two different things, and is perfectly legal. The first
definition would be used if `RGB(' was encountered, and the second
would be used if `RGB?', where `?' is anything but `('. (ref. 2)
If the second behaviour holds true on non-gcc C preprocessors, then I
believe we have solved the problem; we just rename the RGB structure to
allegro_rgb, and provide a #definition of it.
Otherwise, we could test for gcc (#ifdef __GNUC__) and act accordingly.
References:
1. cpp.info, `Cascaded Macros' (`info cpp m m c')
2. cpp.info, `Argument Macros' (`info cpp m a'), line 150ish
Bye for now,
--
Laurence Withers, lwithers@xxxxxxxxxx
http://www.lwithers.demon.co.uk/
Attachment:
signature.asc
Description: PGP signature
| Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |