如何使用stdin管道作为gcc的源输入?

时间:2013-01-28 13:42:25

标签: windows gcc pipe

这是我的尝试:

CMD文件:

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

代码(此处不相关):int main() {}

错误我得到了:

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

我认为-x选项用于表示stdin输入,gcc本身就是这么说的。

1 个答案:

答案 0 :(得分:15)

-x选项指定输入语言,但它不告诉g ++从stdin读取。为此,您可以将单个短划线作为文件名传递。

type test10.cpp | g++ -o test10.exe -x c++ -
相关问题