Xcode Preprocessor Output

2019-01-11 00:32发布

I want to check the output of the preprocessor for some files. How can I view the preprocessor's output in Xcode?

6条回答
小情绪 Triste *
2楼-- · 2019-01-11 01:03

You can always just run the preprocessor on the files from the command line using the -E flag with llvm-gcc (this is what Xcode 4 uses as a replacement for GCC). Something like this:

llvm-gcc -E -o output.preprocess input.c

Then you can just open up the output file in a text editor.

查看更多
对你真心纯属浪费
3楼-- · 2019-01-11 01:04

<menubar> -> Product -> Perform action -> Preprocess <the name of your file>

查看更多
▲ chillily
4楼-- · 2019-01-11 01:06

@whoKnows's excellent and concise answer applies to Xcode 6 users. The preprocessor menu seems to wander all over the place from one Xcode version to another.

To recap: XCode 6 users can view preprocessor output by pulling down this menu:

Product -> Perform Action -> Preprocess

as illustrated in the accompanying screenshot. I couldn't find this anywhere in the Xcode documentation.

(I hope this helps. I would have preferred to simply add a comment to @whoKnows's answer, but I don't have privileges for that yet.)

screenshot of menu pulldowns for viewing preprocessor output

查看更多
兄弟一词,经得起流年.
5楼-- · 2019-01-11 01:07

I did not find any way too. Seems that "Preprocess" feature is missing in Xcode 4. I haven't read any document from apple, where they mentioned anything about this.

Following uri might help you: http://pilky.me/view/15

查看更多
Rolldiameter
6楼-- · 2019-01-11 01:13

Xcode 4.1 features now "Preprocessor or Assembly Output". All be happy!

查看更多
霸刀☆藐视天下
7楼-- · 2019-01-11 01:15

You can choose the "Show the Assistant editor" view in the top right set of buttons in the toolbar.

enter image description here

Then, at the top of the right-hand editor you can click the little Related Files button and then either choose Preprocess or Assembly.

enter image description here

You can see an example of both the preprocessor output and generated assembly code all side-by-side here:

enter image description here

查看更多
登录 后发表回答