Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make GCC output to stdout?

Tags:

c

gcc

GCC is normally instructed to output to a file via the -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?

like image 941
Matt Joiner Avatar asked Aug 13 '10 06:08

Matt Joiner


People also ask

How do I redirect output to a file in gcc?

Try: $ make 2>&1 | tee your_build_log. txt this will redirect stdout, 2>&1 redirects stderr to the same place as stdout while allowing you to simultaneously see the output in your terminal.

Does gcc output assembly?

Luckily, gcc does not output binary machine code directly. Instead, it internally writes assembler code, which then is translated by as into binary machine code (actually, gcc creates more intermediate structures). This internal assembler code can be outputted to a file, with some annotation to make it easier to read.

What is option in gcc?

When you invoke GCC, it normally does preprocessing, compilation, assembly and linking. The "overall options" allow you to stop this process at an intermediate stage. For example, the -c option says not to run the linker.

Which gcc option is used to generate assembly code from C in Linux?

Use the -S option to gcc (or g++), optionally with -fverbose-asm which works well at the default -O0 to attach C names to asm operands as comments.


1 Answers

gcc -o /dev/stdout foo.c 

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

like image 108
sarnold Avatar answered Sep 29 '22 07:09

sarnold