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.
Whenever the script tries to run programs like this, it gets permission errors (weird since I'm running as root
).
Is this accurate and if so, how can I prevent it?
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
%