开发者

How to make GCC output to stdout?

开发者 https://www.devze.com 2023-01-11 15:29 出处:网络
GCC is normally instructed to output to a file via th开发者_如何学编程e -o switch. If this isn\'t provided it seems to decide on an appropriate name and output to that. How do I make GCC write its gen

GCC is normally instructed to output to a file via th开发者_如何学编程e -o switch. If this isn't provided it seems to decide on an appropriate name and output to that. How do I make GCC write its generated output to stdout?


gcc -o /dev/stdout foo.c

Note that /dev/stdout is defined as a symlink: /dev/stdout -> /proc/self/fd/1.


You can use -o-, for example to print an assembly listing:

gcc -S -o- in.c


Um, what are you going to do with a binary object file dumped to stdout? anyway, some programs accept the '-' (single minus, no quotes) character as replacement for stdout. If you're on linux, you can do -o /dev/fd/1

0

精彩评论

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