简体   繁体   中英

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?

You can do this with most compilers, eg 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM