O'Reilly logo

Advanced Mac OS X Programming: The Big Nerd Ranch Guide by Mark Dalrymple

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Seeing Preprocessor Output

Sometimes you get an inscrutable error and have no idea why the compiler is complaining. Or you may have code that looks reasonable and compiles OK, but it behaves in a way that defies sanity even when you take the phase of the moon into account. This is a good time to examine the preprocessor’s output so you can see exactly what the compiler is seeing. The -E flag tells gcc to send the preprocessed source code to standard out. You can use Xcode 3’s Preprocess command as well, or Xcode 4’s generated output.

Example 2.2 looks simple enough. It will read a line from standard in and print it back out.

Example 2.2. preprocTest.m

/​/​ ​p​r​e​p​r​o​c​T​e​s​t​.​m​ ​-​-​ ​a​ ​p​r​o​g​r​a​m​ ​t​o​ ​s​h​o​w​ ​p​r​e​p​r​o​c​e​s​s​o​r​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required