reading from stdin

Erik Leunissen e.leunissen@hccnet.nl
Fri Sep 2 10:11:00 GMT 2005


L.S.

I would like to compile C code by feeding it to gcc (or cc) from stdin, 
instead of specifying an input file. What I want would result in a 
command line like:

     echo "ThisWouldNeedToBeCcode" | gcc -o out.o


(Note aside:
This may look as an awkward or even useless construct at first glance. 
However that's not the point. I supplied this example invocation to keep 
the case simple and to the point. In reality I want to invoke such a 
command from a scripting language, where not using files for input does 
make sense. I do not want to clutter this case with issues regarding the 
scripting language.)


The above command line and several variants that I tried, evoke the 
following complaint:

     gcc: no input files

which, of course, is very much true.


Is reading from stdin simply not supported?


In case it is relevant, here's the output from "gcc -v":

Reading specs from /usr/lib/gcc-lib/i586-suse-linux/3.3.1/specs
Configured with: ../configure --enable-threads=posix --prefix=/usr 
--with-local-prefix=/usr/local --infodir=/usr/share/info 
--mandir=/usr/share/man --libdir=/usr/lib 
--enable-languages=c,c++,f77,objc,java,ada --disable-checking 
--enable-libgcj --with-gxx-include-dir=/usr/include/g++ 
--with-slibdir=/lib --with-system-zlib --enable-shared 
--enable-__cxa_atexit i586-suse-linux
Thread model: posix
gcc version 3.3.1 (SuSE Linux)



Thanks in advance for any help,

Erik Leunissen
==============



More information about the Gcc-help mailing list