开发者

Output to a text file the pre-compiler code

开发者 https://www.devze.com 2022-12-17 08:39 出处:网络
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.

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

精彩评论

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

关注公众号