the Reverend
the Reverend

Reputation: 12549

New build settings with LLVM Compiler on macros

I just created a new cocoa project on Xcode 4.3.3. The preprocessor macros for the Apple LLVM compiler 3.1 settings have a DEBUG=1 $(inherited) value assigned. I removed it and add it again, and now I'm getting an error when compiling :

clang: error: no such file or directory: 'DEBUG=1'

I search for the value on the project settings and I saw that the value is also defined in "Other warning flags"

My questions are:

  1. What is the difference between just having DEBUG vs DEBUG=1?
  2. What does $(inherited) do?
  3. What is it also doing on the other warning flags?

Upvotes: 1

Views: 1910

Answers (1)

Jason Coco
Jason Coco

Reputation: 78343

First, if you're getting a compilation error, then you most likely put the macro back in the incorrect place in the project settings. Please ensure you've put it into the Debug configuration branch of the Preprocessor Macros item under the Apple LLVM compiler x.x - Preprocessing section.

For your other questions:

  1. The first version just defines the macro DEBUG so it's essentially empty. You can test for whether it exists or does not exist, but not much. The second sets it to 1 so that the preprocessor can actually do comparisons like #if DEBUG && SHOULD_DIE_ON_ERROR where you might abort if the application comes across some validation error, but only if SHOULD_DIE_ON_ERROR is set and 1 and you're running in debug mode.
  2. The $(inherited) just brings in other macros you're inheriting from further up the chain. So if your project defines some items and your target defines some more, the target gets the project's settings as well without having to re-define them.
  3. It shouldn't be effecting the warning flags at all. If anything, it determines code paths in header files you include (like the cocoa frameworks) which may use different implementations for things or may add debugging information to data structures, or whatever.

Upvotes: 1

Related Questions