This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Making gcc read from the standard input
- From: Paolo Bonzini <paolo dot bonzini at lu dot unisi dot ch>
- To: Tathagato Rai Dastidar <Tathagato dot Rai dot Dastidar at nsc dot com>, gcc-help at gcc dot gnu dot org, GCC Development <gcc at gcc dot gnu dot org>
- Date: Thu, 11 Jan 2007 10:12:28 +0100
- Subject: Re: Making gcc read from the standard input
- References: <45A5D958.50100@nsc.com>
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