xcode C、Objective-C 预处理器输出
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2823180/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C, Objective-C preprocessor output
提问by John Smith
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.
有没有办法获得预处理的C/Objective-C 代码?我有一些我获得的文件,并希望看到一些#defines 生成的代码。
回答by Paul R
From within Xcode:
从 Xcode 中:
- Xcode 3: Select the file, then Build → Preprocess.
- Xcode 4: Select the file, then Product → Generate Output → Generate Preprocessed File.
- Xcode 3:选择文件,然后Build → Preprocess。
- Xcode 4:选择文件,然后Product → Generate Output → Generate Preprocessed File。
回答by Mark Rushakoff
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.
在命令行上,gcc -E foo.m
将显示预处理的输出(就像对普通 C/C++ 文件所做的那样)。当然,这也会扩展您的代码中可能包含的任何#include
or#import
语句。
回答by Nate
Use the -E
command-line argument to gcc
or clang
. This is documented as: “Preprocess only; do not compile, assemble or link” and indeed it outputs the preprocessed version to stdout
.
使用-E
命令行参数gcc
或clang
。这被记录为:“仅预处理;不编译、汇编或链接”,实际上它将预处理版本输出到stdout
.
回答by jctank
In Xcode 5: Select the .m file, then Product -> Perform Action -> Preprocess ".m"
在 Xcode 5 中:选择.m 文件,然后选择Product -> Perform Action -> Preprocess ".m"