[wx-dev] Macros and brackets
Manuel Martín
mmartin at ceyd.es
Mon Jun 30 07:46:36 PDT 2008
Hi
Trying a simple 'if/else' like this:
if (mycondition)
wxDELETE(myptr);
else
Dothings();
I've got this gcc 4.2.1 compiler error:
"error: expected primary-expression before 'else'"
I think it is due to macro-expansion in several lines (and
I didn't use brackets), because changing to {wxDELETE(myptr);}
solves the problem.
So, the question:
Should be wx macros defined inside brackets? i.e, from defs.h:
-- #define wxDELETE(p) if ( (p) != NULL ) { delete p; p = NULL; }
++ #define wxDELETE(p) {if ( (p) != NULL ) { delete p; p = NULL; }}
TIA
Manolo
More information about the wx-dev
mailing list