Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 262
John Smith Avatar asked May 12 '10 22:05

John Smith


People also ask

What is the output of preprocessor?

When the C preprocessor is used with the C, C++, or Objective-C compilers, it is integrated into the compiler and communicates a stream of binary tokens directly to the compiler's parser. However, it can also be used in the more conventional standalone mode, where it produces textual output.

What is preprocessor in Objective-C?

The Objective-C Preprocessor is not part of the compiler, but is a separate step in the compilation process. In simplistic terms, an Objective-C Preprocessor is just a text substitution tool and it instructs compiler to do required pre-processing before actual compilation.

How do I see the preprocessor output in clang?

On the command line, gcc -E foo. m will show you the preprocessed output (just as it does for normal C/C++ files).

What is a macro Objective-C?

Macros can be used in many languages, it's not a specialty of objective-c language. Macros are preprocessor definitions. What this means is that before your code is compiled, the preprocessor scans your code and, amongst other things, substitutes the definition of your macro wherever it sees the name of your macro.


2 Answers

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.

like image 131
Mark Rushakoff Avatar answered Oct 23 '22 01:10

Mark Rushakoff


From within Xcode:

  • Xcode 3: Select the file, then Build → Preprocess.
  • Xcode 4: Select the file, then Product → Generate Output → Generate Preprocessed File.
like image 22
Paul R Avatar answered Oct 23 '22 02:10

Paul R