Does g++ still generate an output file even if the program fails to compile/load?
I am compiling some 开发者_开发百科C++ programs through a perl script using:
g++ -o out `find ./ -iname "*.h" -or -iname "*.cpp"`
This seems to generate an an out
file every time, regardless of whether the program compiled successfully or not.
root
).
Is this accurate and if so, how can I prevent it?
Thanks.
The answer to your title's question ("Does g++ still generate an output file even if the program fails to compile/load?") is no:
% 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
%
I solved it as follows:
For some reason, trying to put the output executable using -o out
seemed to force creating the file even after the compile failed (it seems to me).
g++ -o out.tmp `find ./ -iname "*.h" -or -iname "*.cpp"` && mv out.tmp out
精彩评论