Search code examples
swiftpreprocessor-directive

Swift preprocessor if not flag


Is there a Swift compiler directive for #if not?

I know this could work

#if myFlag
    // ignore
#else 
    bar()
#endif

But it is not pretty if there is nothing between if and else.


Solution

  • I wasn't trying enough, I found out

    #if !myFlag 
    
    #endif 
    

    works well !