Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
957 views
in Technique[技术] by (71.8m points)

command line - Is it possible to get GCC to read from a pipe?

I'm looking for an option to gcc that will make it read a source file from the standard input, mainly so I could do something like this to generate an object file from a tool like flex that generates C code (flex's -t option writes the generated C to the standard output):

flex -t lexer.l | gcc -o lexer.o -magic-option-here

because I don't really care about the generated C file.

Does something like this exist, or do I have to use temporary files?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 -

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...