在g ++中使用-pass-exit-codes时出现意外的退出状态 [英] Unexpected exit status when using -pass-exit-codes in g++

查看:270
本文介绍了在g ++中使用-pass-exit-codes时出现意外的退出状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

执行以下操作时,失败的编译的退出代码为1,但基于,我希望它是> = 3。为什么是这样?如果我想要比二进制成功/失败更详细的退出代码,我该怎么办?

When doing the following, the exit code of the failed compilation is 1, however, based on this, I would expect it to be >=3. Why is this? What can I do if I want more detailed exit codes than binary success/fail?

> echo "int main() {fail}" > fail.cpp
> g++ -pass-exit-codes fail.cpp -o fail
fail.cpp: In function ‘int main()’:
fail.cpp:1: error: ‘fail’ was not declared in this scope
fail.cpp:1: error: expected ';' before ‘}’ token
> echo $?
1
> g++ --version
g++ (GCC) 4.1.3 20080704 (Red Hat 4.1.2-27)


$ b b

感谢。

Thanks.

推荐答案

您指向的文档属于gcc版本3.3.6。但是,在版本> = 4中,该编译器标志的文档已更改,现在仅声明:

The documentation that you point at belongs to gcc version 3.3.6. However, in version >=4, the documentation for that compiler flag has changed and it now only states:


-pass-exit-codes

通常,如果编译器的任何阶段返回非成功返回码,则gcc程序退出,代码为1。如果指定
-pass-exit-codes,gcc程序将返回一个数字最高的错误,任何阶段返回一个错误
指示。如果遇到内部编译器错误,C,C ++和Fortran前端返回4。

-pass-exit-codes
Normally the gcc program exits with the code of 1 if any phase of the compiler returns a non-success return code. If you specify -pass-exit-codes, the gcc program instead returns with the numerically highest error produced by any phase returning an error indication. The C, C++, and Fortran front ends return 4 if an internal compiler error is encountered.

这是一个有点混乱, 。它没有指定在3.x的文档中很好地解释的错误代码。然后,可能的是,您正在寻找的退出代码不再生成版本4.x的gcc / g ++。

Which is a little confusing when reading it. It does not specify the error codes that were well explained in the documentation of 3.x. Then, it is possible that the exit code that you are looking for is not generated any more in version 4.x of gcc/g++.

这篇关于在g ++中使用-pass-exit-codes时出现意外的退出状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆