| cb9801ac | 11-May-2010 |
Jed Brown <jed@59A2.org> |
Make error macros nest in cascading if statements, revert Hong's reversion of Barry's breakage
The
#define MACRO(x,y) do { multiple(x); statements(y); } while (0)
construct requires the user to
Make error macros nest in cascading if statements, revert Hong's reversion of Barry's breakage
The
#define MACRO(x,y) do { multiple(x); statements(y); } while (0)
construct requires the user to provide a closing semicolon (this patch fixes this problem in many places), and does the correct thing in cascading if statements. Note that the alternative
#define MACRO(x,y) { multiple(x); statements(y); }
expands
if (cond) MACRO(x); else other();
as
if (cond) { multiple(x); statements; } ; else other();
and the final statement is an else with no matching if. I suggest that PETSc adopt the do {} while (0) construct anywhere that it currently uses compound statements within unguarded braces (note that most PETSc macros return a value and thus do not have this problem).
Hg-commit: ecf653b2f268465b7e7cb7569f7b80897acb163a
show more ...
|