David Ayers wrote:
Richard Frith-Macdonald wrote:
[snip]
However, while the definition above *might* be appropriate for
production code, I think it is wrong for a development
system, and certainly if NDEBUG is not defined I think it should be
of the form -
#define isYES(_exp) ((_exp) == YES) ? 1 : (((_exp) == 0) ? NO :
([NSException raise...],0)
Well, actually this will probably have to be done in a (static
inline) function to avoid evaluating the expression mutliple times
...
Just to clarify, I don't mean making isYES a function, I mean:
#ifndef isYES
#ifndef NDEBUG
#define isYES (_exp) (_exp != NO)
/* or even just: (_exp) if exp != NO is such a bad style. */
#else
#define isYES (_exp) (_GSAssertBOOL(_exp))
#endif
#endif
...
STATIC_INLINE BOOL
_GSAssertBOOL(BOOL val)
{
return (val == YES ? 1 : ((val == NO) ? NO
: ([NSException raise...],0))
}
or something similar.