c++ - 即使程序无法编译/加载,g++ 是否仍会生成输出文件?

标签 c++ compiler-construction g++

我正在通过 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/

相关文章:

Python脚本路径编译后保持不变

compiler-construction - LLVM,通过引用调用

c# - 如果 C# 中的关键字未在系统类中定义,那么它们在 CLR 中的哪里?

cmd - 如何将 Unicode 参数传递给 G++?

c++ - 无法在 C++ 控制台应用程序项目中包含头文件

c++ - C++ 编译器使用什么类型的程序集?

c++ - 将 shared_ptr 参数添加到容器的有效方法?

c++ - STL 容器库 - 在分配器类的不同实例上调用分配/解除分配是否合法?

c++ - 使用 haskell 构建动态库并在 C++ 中使用它

c++ - ld : duplicate symbol. g++