Making gcc read from the standard input
Paolo Bonzini
paolo.bonzini@lu.unisi.ch
Thu Jan 11 09:12:00 GMT 2007
Tathagato Rai Dastidar wrote:
> Hello,
>
> Is there a way I can make GCC read a C or C++ code from the standard
> input instead of from a file?
>
> In my application software, I am generating some C code on the fly,
> writing it to a file, then using GCC to compile it. Instead of that, I
> want to invoke GCC through a pipe, and write the C code directly into
> GCC, instead of writing it into a file and then calling GCC.
>
> Is this possible?
This is a question only for gcc-help. Cross-posting gcc and gcc-help is
almost always wrong. :-) But yes, it is possible by adding "-x c" to
the command line, so that the gcc driver knows which front-end to
invoke. In the case of "-E", in fact, GCC implicitly considers the
language to be C (and invokes the C front-end) because the preprocessor
is the same for all input languages; but for real compilation, you need
to specify the language manually.
HTH,
Paolo
More information about the Gcc-help
mailing list