加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 如何从stdin编译代码?

发布时间:2020-12-16 07:51:54 所属栏目:百科 来源:网络整理
导读:参见英文答案 Is it possible to get gcc to read from a pipe?2 Compiling C++-code without a file5个 代码很简单: test$cat test.cppint main(){} 有没有办法编译来自标准输出的代码? 我试过这个: cat test.cpp | g++ - 和一些变化,但没有一个可执行.
参见英文答案 > Is it possible to get gcc to read from a pipe?2
> Compiling C++-code without a file5个
代码很简单:
test$cat test.cpp

int main()
{
}

有没有办法编译来自标准输出的代码?

我试过这个:

cat test.cpp | g++ -

和一些变化,但没有一个可执行.

只是一些澄清.我有一个预处理文件的程序,并生成另一个我要编译的文件.我想到没有创建这个中间文件,而是直接生成对象文件.

解决方法

编译器可能会告诉你:
-E or -x required when input is from standard input

尝试

cat test.cpp | g++ -x c++ -

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读