Is it possible to get GCC to read from a pipe?

flex -t lexer.l | gcc -x c -c -o lexer.o -

Basically you say that the filename is -. Specifying that a filename is - is a somewhat standard convention for saying 'standard input'. You also want the -c flag so you're not doing linking. And when GCC reads from standard input, you have to tell it what language this is with -x . -x c says it's C code.


Yes, but you have to specify the language using the -x option:

# Specify input file as stdin, language as C
flex -t lexer.l | gcc -o lexer.o -xc -