Add wxDO_IF() helper macro
This will be used for wxLogXXX() macros reimplementation in the next commit.
This commit is contained in:
parent
ea2bff0b50
commit
8c378b44e2
@ -96,6 +96,27 @@
|
||||
#define wxSTATEMENT_MACRO_BEGIN do {
|
||||
#define wxSTATEMENT_MACRO_END } while ( (void)0, 0 )
|
||||
|
||||
/*
|
||||
Helper for executing the following statement conditionally without using
|
||||
conditional statements.
|
||||
|
||||
This strange macro is needed in the first place to avoid the problems due
|
||||
to nested if/else inside macros. E.g. if some MACRO started with "if", then
|
||||
|
||||
if ( cond )
|
||||
MACRO();
|
||||
else
|
||||
...
|
||||
|
||||
would be broken because "..." would bind to the wrong "if" inside the macro
|
||||
rather than the visible one. So we use wxDO_IF() inside the macro instead
|
||||
to avoid this problem.
|
||||
*/
|
||||
#define wxDO_IF_HELPER(loopvar, condition) \
|
||||
for ( bool loopvar = false; !loopvar && condition; loopvar = true )
|
||||
|
||||
#define wxDO_IF(condition) wxDO_IF_HELPER(wxMAKE_UNIQUE_NAME(wxdoif), condition)
|
||||
|
||||
/*
|
||||
Define __WXFUNCTION__ which is like standard __FUNCTION__ but defined as
|
||||
NULL for the compilers which don't support the latter.
|
||||
|
Loading…
Reference in New Issue
Block a user