在C中编译数据流?

Kaz*_*ara 6 c compilation stream

是否可以编译数据流而不是.c使用gcc 编译文件?例如,xyz.c我可以直接编译代码,而不是将我的代码存储在任何文件中吗?

pmg*_*pmg 8

使用gcc选项-x-

$ echo -e '#include <stdio.h>\nmain(){puts("Hello world");return 0;}' | gcc -xc -ogarbage - && ./garbage && rm garbage
Hello world

上面的单行命令由以下部分组成:

echo -e '#include <stdio.h>\nmain(){puts("Hello world");return 0;}' # "source"
|                                                                   # pipe
gcc -xc -ogarbage -                                                 # compile
&&                                                                  # and
./garbage                                                           # run
&&                                                                  # and
rm garbage                                                          # delete