我正在通过 perl 脚本编译一些 C++ 程序,使用:
g++ -o out `find ./ -iname "*.h" -or -iname "*.cpp"`
这样好像每次都会生成一个out
文件,不管程序编译成功与否。
每当脚本尝试运行这样的程序时,它都会出现权限错误(很奇怪,因为我是以 root
身份运行的)。
这是否准确?如果准确,我该如何预防?
谢谢。
最佳答案
标题问题的答案(“即使程序编译/加载失败,g++ 是否仍会生成输出文件?”)是否定的:
% echo blah > test.cpp
% g++ -o out test.cpp
test.cpp:1: error: expected constructor, destructor, or type conversion at end of input
% ls *out*
/bin/ls: *out*: No such file or directory
%
关于c++ - 即使程序无法编译/加载,g++ 是否仍会生成输出文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3919675/