Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use stdin pipe as source input for gcc?

Tags:

windows

gcc

pipe

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.

like image 820
rsk82 Avatar asked Jan 28 '13 13:01

rsk82


1 Answers

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++ -
like image 63
John Kugelman Avatar answered Oct 03 '22 23:10

John Kugelman