how to use stdin pipe as source input for gcc?

笑着哭i 提交于 2019-12-23 08:03:25

问题


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.


回答1:


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++ -


来源:https://stackoverflow.com/questions/14563343/how-to-use-stdin-pipe-as-source-input-for-gcc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!