3

I want to add preprocessor macros for a couple files in my project, but not all the files. They're 3rd party sources, so I don't want to edit the files, as to avoid merge maintenance hassle when new versions come along. They happen to interfere with #defines used in other files in the project.

Can XCode 4 compile only certain files with different preprocessor settings than the others?

1 Answer 1

4

In your target's Build Phases tab, you can set compiler flags for individual files under the Compile Sources drop-down. GCC provides a lengthy list of options, but they should work equally well for LLVM.

To define a macro, say FOO, for a specific file, add the -D FOO flag to the "Compiler Flags" entry next to that file.

To un-define a macro FOO, add the flag -U FOO.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.