如何在 Sun Studio 12 中禁用系统头的警告

发布于 2024-10-14 12:21:57 字数 400 浏览 3 评论 0原文

我们正在通过(除其他外)修复所有编译器警告来整理我们的代码库。

最终目标是打开将所有警告转换为错误的标志。我们在系统和第三方标头方面遇到了一些小问题。某些系统标头会导致各种编译器发出警告。现在显然我们不能去修改系统标头来修复这些警告。

使用英特尔编译器(和 gcc),您只需在构建包含路径时使用 -isystem 而不是 -I 来告诉编译器这些目录中的标头是系统标头,并且它会停止发出有关它们的警告。然后打开 -Werror 标志就很简单了。

我们还使用 Sun Studio 12,标志 -errwarn=%all 应该相当于 -Werror,但我找不到一种方法来告诉编译器忽略系统/第三方标头中的警告。有 -errdr 标志,但这似乎没有达到我想要的效果。

有谁知道如何使用 Sun Studio 12 来实现这一点?

We're in the middle of tidying up our codebase by (among other things) fixing all the compiler warnings.

The end goal is to turn on the flag that converts all warnings to errors. We've run into a slight snag with system and thirdparty headers. Some of the system headers cause the various compilers to emit warnings. Now obviously we can't go modifying system headers to fix those warnings.

With the intel compiler (and gcc) you simply use -isystem instead of -I when building up the include path to tell the compilers that headers in those dirs are system headers and it stops warning about them. Then it's a simple matter of turning on the -Werror flag.

We're also using Sun Studio 12, the flag -errwarn=%all should be the equivalent of -Werror, but I can't find a way to tell the compiler to ignore warnings in system / thirdparty headers. There is the -errhdr flag, but this doesn't seem to do what I want.

Does anyone know how to accomplish this with Sun Studio 12?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

左秋 2024-10-21 12:21:57

显然,这并不完全是您想要的,但在没有更好的情况下,您可以将有问题的包含内容包装在 #pragma error_messages 块中。例如,

#pragma error_messages (on , tag .. tag)

#include <map>
// etc

#pragma error_messages (default , tag .. tag)

此处所述。我目前无法访问 Solaris,因此我还没有尝试过此操作。

Obviously, this isn't exactly what you want but in the absence of anything better you could wrap the offending includes in a #pragma error_messages block. E.g.

#pragma error_messages (on , tag .. tag)

#include <map>
// etc

#pragma error_messages (default , tag .. tag)

as described here. I don't currently have access to Solaris so I haven't tried this.

简单气质女生网名 2024-10-21 12:21:57

另一种选择是使用 -errtags 查看警告标记,然后使用 -erroff 关闭特定警告。

Another option is to look at the warning tag using -errtags, and then switch off the particular warning with -erroff.

唔猫 2024-10-21 12:21:57

不幸的是(据我所知),errhdr 标志是你能得到的最好的标志。很高兴您正在使用 Sun Studio 12,因为它刚刚添加到该版本中。

Unfortunately (as far as I know), the errhdr flag is the best you can get. Be happy that you are using Sun Studio 12, since it was only just added in that release.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文