how to use stdin pipe as source input for gcc? how to use stdin pipe as source input for gcc? windows windows

how to use stdin pipe as source input for gcc?


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


you can use here doc in the interactive shell.for example:

gcc -x c - <<eof#include <stdio.h>void foo(){    int a = 10;    static int sa = 10;    a += 5;    sa += 5;    printf("a = %d, sa = %d\n", a, sa);}int main(){    int i;    for (i = 0; i < 10; ++i)        foo();}eof

reference