This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Making gcc read from the standard input


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]