Re: reading from stdin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Erik Leunissen <e.leunissen@xxxxxxxxx> writes:

> 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

In gcc 4 you can do this:
    echo 'int main() { printf ("Hello, world\n"); }' | gcc -xc - -o out

The '-' tells gcc to read stdin.  The '-xc' tells gcc that the input
is in C (rather than, say, C++).

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux