如何在 Sun Studio 12 中禁用系统头的警告
我们正在通过(除其他外)修复所有编译器警告来整理我们的代码库。
最终目标是打开将所有警告转换为错误的标志。我们在系统和第三方标头方面遇到了一些小问题。某些系统标头会导致各种编译器发出警告。现在显然我们不能去修改系统标头来修复这些警告。
使用英特尔编译器(和 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
显然,这并不完全是您想要的,但在没有更好的情况下,您可以将有问题的包含内容包装在 #pragma error_messages 块中。例如,
如此处所述。我目前无法访问 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.
as described here. I don't currently have access to Solaris so I haven't tried this.
另一种选择是使用 -errtags 查看警告标记,然后使用 -erroff 关闭特定警告。
Another option is to look at the warning tag using -errtags, and then switch off the particular warning with -erroff.
不幸的是(据我所知),
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.