在g ++中管理文件内容以进行编译 [英] Pipe file contents in g++ to compile
本文介绍了在g ++中管理文件内容以进行编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以将文件内容传递给 g ++
来编译程序?
我想这样做是因为我想使用数据库中的文件而不是磁盘上的物理文件。文件内容可以很容易地通过我已经制作的API检索。
例如,我想要做类似的事情:
g ++ contents_of_file -o可执行文件
谢谢很多。
山姆。
解决方案
gcc,如果您使用 -x
选项指定语言;
echo int main(){}| gcc -Wall -o testbinary -xc ++ -
Is it possible to pipe the contents of a file into g++
to compile a program?
I want to do this because I want to use a file from a database rather than a physical file on a disk. The file contents can be easily retrieved via an API I have made.
For instance, I would like to do something like:
g++ contents_of_file -o executable
Thanks a lot.
Sam.
解决方案
Yes, you can pipe to gcc if you specify the language using the -x
option;
echo "int main(){}" | gcc -Wall -o testbinary -xc++ -
这篇关于在g ++中管理文件内容以进行编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文