簡體   English   中英

即使程序無法編譯/加載,g ++仍會生成輸出文件嗎?

[英]Does g++ still generate an output file even if the program fails to compile/load?

我通過使用以下命令的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
%

我解決了如下問題:
由於某種原因,即使編譯失敗后,嘗試使用-o out輸出輸出可執行文件似乎也會強制創建文件(在我看來)。

g++ -o out.tmp `find ./ -iname "*.h" -or -iname "*.cpp"` && mv out.tmp out

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM