SunStudio C++ 编译器编译指示禁用警告?

发布于 2024-07-13 16:13:12 字数 440 浏览 7 评论 0原文

与 SunStudio11 捆绑在一起的 STLport 会生成大量警告。 我相信大多数编译器都有办法禁用某些源文件的警告,如下所示:

Sun C

#pragma error_messages off

#include <header.h>
// ...

#pragma error_messages on

gcc

#pragma warning(push, 0)        

#include <header.h>
// ...

#pragma warning(pop)

How do you do this in the SunStudio C++ compiler? (顺便说一句,sunstudio C 编译指示在 sunstudio C++ 中不起作用)

The STLport bundled with the SunStudio11 generates alot of warnings. I beleive most compilers have a way to disable warnings from certain source files, like this:

Sun C

#pragma error_messages off

#include <header.h>
// ...

#pragma error_messages on

gcc

#pragma warning(push, 0)        

#include <header.h>
// ...

#pragma warning(pop)

How do you do this in the SunStudio C++ compiler? (btw, the sunstudio C pragmas don't work in sunstudio C++)

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

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

发布评论

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

评论(4

久隐师 2024-07-20 16:13:12

在 SunStudio 12 中,#pragma error_messages 的工作方式如 C 用户手册中所述。

您可以使用 -errtags=yes 选项查看标签,并像这样使用它:

// Disable badargtypel2w:
//     String literal converted to char* in formal argument
#pragma error_messages (off, badargtypel2w )

然后使用 CC(C++ 编译器)进行编译。

In SunStudio 12, the #pragma error_messages work as documented in the C users manual.

You can see the tags with the -errtags=yes option, and use it like this:

// Disable badargtypel2w:
//     String literal converted to char* in formal argument
#pragma error_messages (off, badargtypel2w )

and then compile with CC (the C++ compiler).

歌入人心 2024-07-20 16:13:12

如果您更愿意使用命令行选项而不是 #pragmas,一个简单的答案是您可以在编译行上使用 -erroff=%all。

您可以使用 -erroff=% 抑制特定警告消息tag

您可以通过将 -errtags 添加到编译行来打印警告消息的标签。 然后,您可以为 -erroff 定义一组以逗号分隔的值,仅抑制这些标签。

请参阅 http://docs.oracle.com/cd /E19205-01/820-7599/bkapa/index.html 了解更多信息。

请注意,Sun Studio 12 update 1 现已推出,我在此处引用了 SS12u1 文档。

If you'd rather use a command line option than #pragmas, a simple answer is that you can use -erroff=%all on your compile line.

You can suppress specific warning messages with -erroff=%tag

You can print out the tags for the warning messages by adding -errtags to your compile line. You can then define a set of comma-separated values for -erroff that suppress just those tags.

See http://docs.oracle.com/cd/E19205-01/820-7599/bkapa/index.html for more info.

Note that Sun Studio 12 update 1 is now available, and I'm referencing the SS12u1 doc here.

初见 2024-07-20 16:13:12

无法关闭警告,但当我上次查看 SunStudio 时,它附带了两个 STL - 一个旧的用于向后兼容早期编译器版本和 STLport。 在尝试关闭警告之前,可能值得检查一下您是否正在使用 STLport。

Can't help with turning the warnings off, but when I last looked at SunStudio, it shipped with two STLs - an older one for backward compatibility with earlier compiler versions and STLport. Might be worth checking if you're using STLport before trying to trying to turn off the warnings.

小嗷兮 2024-07-20 16:13:12

将 -w 添加到您的 $CC 或您使用的任何变量中。

add -w to your $CC or whatever var you use.

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