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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 19:21:25  来源:igfitidea点击:

C, Objective-C preprocessor output

objective-ccxcodec-preprocessor

提问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.mwill show you the preprocessed output (just as it does for normal C/C++ files). Of course, this will also expand any #includeor #importstatements you may have in your code.

在命令行上,gcc -E foo.m将显示预处理的输出(就像对普通 C/C++ 文件所做的那样)。当然,这也会扩展您的代码中可能包含的任何#includeor#import语句。

回答by Nate

Use the -Ecommand-line argument to gccor clang. This is documented as: “Preprocess only; do not compile, assemble or link” and indeed it outputs the preprocessed version to stdout.

使用-E命令行参数gccclang。这被记录为:“仅预处理;不编译、汇编或链接”,实际上它将预处理版本输出到stdout.

回答by jctank

In Xcode 5: Select the .m file, then Product -> Perform Action -> Preprocess ".m"

在 Xcode 5 中:选择.m 文件,然后选择Product -> Perform Action -> Preprocess ".m"