是否可以让 GCC 从管道中读取? [英] Is it possible to get GCC to read from a pipe?

查看:31
本文介绍了是否可以让 GCC 从管道中读取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找 gcc 的一个选项,它可以让它从标准输入中读取一个源文件,主要是为了我可以做这样的事情来从像 flex 生成 C 代码(flex-t 选项将生成的 C 写入标准输出):

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

因为我并不真正关心生成的 C 文件.

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

是否存在这样的东西,或者我必须使用临时文件?

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

推荐答案

可以,但是您必须使用 -x 选项指定语言:

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 -

这篇关于是否可以让 GCC 从管道中读取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆