user4951
user4951

Reputation: 33080

Is there a way to check how a macro "expands" in C or Objective-C

A macro 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?

Upvotes: 7

Views: 6224

Answers (1)

Paul R
Paul R

Reputation: 212959

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

Upvotes: 13

Related Questions