John Smith
John Smith

Reputation: 12807

C, Objective-C preprocessor output

Is there a way to get pre-processed C/Objective-C code? I have some files I acquired and would like to see the code produced by some #defines.

Upvotes: 14

Views: 12103

Answers (4)

jctank
jctank

Reputation: 181

In Xcode 5: Select the .m file, then Product -> Perform Action -> Preprocess ".m"

Upvotes: 3

Paul R
Paul R

Reputation: 213190

From within Xcode:

  • Xcode 3: Select the file, then Build → Preprocess.
  • Xcode 4: Select the file, then Product → Generate Output → Generate Preprocessed File.

Upvotes: 23

Mark Rushakoff
Mark Rushakoff

Reputation: 258498

On the command line, gcc -E foo.m will show you the preprocessed output (just as it does for normal C/C++ files). Of course, this will also expand any #include or #import statements you may have in your code.

Upvotes: 17

Nate
Nate

Reputation: 19030

Use the -E command-line argument to gcc or clang. This is documented as: “Preprocess only; do not compile, assemble or link” and indeed it outputs the preprocessed version to stdout.

Upvotes: 7

Related Questions