如何使用stdin管道作为gcc的源输入? [英] how to use stdin pipe as source input for gcc?

查看:141
本文介绍了如何使用stdin管道作为gcc的源输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



CMD文件:

  @SET PATH =%PATH%; D:\mingw\bin 
type test10.cpp | g ++ -xc ++ -o test10.exe

代码(无关): int main(){}



错误我得到:

  g ++:致命错误:没有输入文件
编译终止。

我以为-x选项是用来标示stdin输入,gcc本身就是这么说的。 p>

解决方案告诉g ++从标准输入读取。要做到这一点,你可以传递一个破折号作为文件名。

  type test10.cpp | g ++ -o test10.exe -x c ++  -  


This is my try:

CMD file:

@SET PATH=%PATH%;D:\mingw\bin
type test10.cpp | g++ -xc++ -o test10.exe

code (irrelevant here): int main() {}

error I get:

g++: fatal error: no input files
compilation terminated.

I thought that the -x option is for signalizing stdin input, gcc itself said me that.

解决方案

The -x option specifies the input language, but it doesn't tell g++ to read from stdin. To do that, you can pass a single dash as a file name.

type test10.cpp | g++ -o test10.exe -x c++ -

这篇关于如何使用stdin管道作为gcc的源输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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