Objective-C preprocessor directive for 'if not'
you could try:
#if !(SOME_VARIABLE) // Do something#endif
Are you trying to check if something is defined or not?If yes, you can try:
#ifndef SOME_VARIABLE
or
#if !defined(SOME_VARIABLE)
The Apple documentation (If - The C Preprocessor) is correct and this is the way that C pre-processor statements have been since the dawn of time. As per that same documentation all you can do is craft an expression that evaluates to either zero or a non-zero value and use that.
Meccan's answers is correct as TARGET_IPHONE_SIMULATOR
is defined as TRUE
or FALSE
depending on the platform, so the expression will evaluate to either zero or a non-zero amount.
In general these macros (#if
etc) are used for including or excluding things based on whether a symbol is defined or not. For that use case the pre-processor has #ifdef
and #ifndef
which covers what has historically been accepted as the most important cases.
Also given that the subject of these statements can only be other pre-processor defined symbols (via #define
) then this limitation is reasonable.