Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCode Preprocessor macro #if still includes code contrary that the symbol is defined to 0

I have a preprocessor macro in my XCODE project called LINPHONE_DEBUG. In my build settings, I have set the macro to 0 exactly like this: LINPHONE_DEBUG=0.

But somehow when I use this code:

#if LINPHONE_DEBUG
    foo()
#endif

The foo() is still called see the screenshot below.

enter image description here

You can see that I printed po LINPHONE_DEBUG and it is 0, but it still reached the code.

I am running XCODE 6.4 (6E35b).

like image 967
Tomas Sykora Avatar asked Dec 20 '25 18:12

Tomas Sykora


1 Answers

From the Swift iBook: Using Swift with Cocoa and Objective-C (Swift 2 Prerease)

“The Swift compiler does not include a preprocessor. Instead, it takes advantage of compile-time attributes, build configurations, and language features to accomplish the same functionality. For this reason, preprocessor directives are not imported in Swift.”

“Build Configurations Swift code and Objective-C code are conditionally compiled in different ways. Swift code can be conditionally compiled based on the evaluation of build configurations. Build configurations include the literal true and false values, command line flags, and the platform-testing functions listed in the table below. You can specify command line flags using -D <#flag#>.”

See the documentation for more information on Build Configurations.

like image 182
zaph Avatar answered Dec 23 '25 09:12

zaph



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!