开发者

Output to a text file the pre-compiler code

gcc 4.4.2 c89

I have a file called main.c.

I want the result of the pre-comiler and save it to a text file.

I have done the following which creates a text file, but there is nothing in it. It is zer开发者_StackOverflow社区o bytes.

gcc -E main.c | > main.txt

Many thanks for any suggestions,


Apart from the obvious error:

gcc -E main.c > main.txt

... you can also use the C preprocessor directly:

cpp main.c > output.c

...which has the added benefit of being independed of the compiler and possible to use in another toolchain.

In both cases in case of problems, take a look at preprocessor command line options.


You don't need to use a pipe operator for redirecting output to a text file. Just use

gcc -E main.c > main.txt


get rid of the |, or use gcc -E main.c -o main.txt.


You might want to look into the ‘cpp‘ program, which is the C preprocessor that gcc uses.

cpp in.c > out.c
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜