Is there a way to check how a macro "expands" in C or Objective-C
A mac开发者_开发问答ro is a preprocessor right. Sometimes we set things right sometimes we don't.
Wouldn't it be nice to once in a while expand the macro and see how it works?
You can do this with most compilers, e.g. with gcc:
$ gcc -E
this just runs the preprocessor and then stops, giving you the pre-processed output on stdout.
If you're using Xcode though you don't even need to do this - depending on what version of Xcode you're using you can just select Preprocess
from the Build
menu (that's what its called in Xcode 3.x - if you're using Xcode 4 it may have been moved/renamed). See: Xcode Preprocessor Output
精彩评论