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:
与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? (btw, the sunstudio C pragmas don't work in sunstudio C++)
你如何在SunStudio C ++编译器中做到这一点? (顺便说一句,sunstudio C pragma在sunstudio C ++中不起作用)
4 个解决方案
#1
In SunStudio 12, the #pragma error_messages work as documented in the C users manual.
在SunStudio 12中,#pragma error_messages的工作方式如C用户手册中所述。
You can see the tags with the -errtags=yes option, and use it like this:
您可以使用-errtags = yes选项查看标记,并像这样使用它:
// Disable badargtypel2w:
// String literal converted to char* in formal argument
#pragma error_messages (off, badargtypel2w )
and then compile with CC (the C++ compiler).
然后使用CC(C ++编译器)进行编译。
#2
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.
如果你宁愿使用命令行选项而不是#pragmas,一个简单的答案就是你可以在编译行上使用-erroff =%all。
You can suppress specific warning messages with -erroff=%tag
您可以使用-erroff =%标记来禁止特定警告消息
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.
您可以通过在编译行中添加-errtags来打印警告消息的标记。然后,您可以为-erroff定义一组逗号分隔值,仅抑制这些标记。
See http://docs.oracle.com/cd/E19205-01/820-7599/bkapa/index.html for more info.
有关详细信息,请参阅http://docs.oracle.com/cd/E19205-01/820-7599/bkapa/index.html。
Note that Sun Studio 12 update 1 is now available, and I'm referencing the SS12u1 doc here.
请注意,Sun Studio 12更新1现已可用,我在此处引用了SS12u1文档。
#3
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.
无法关闭警告,但是当我上次查看SunStudio时,它附带了两个STL - 一个较旧的STL,用于向后兼容早期的编译器版本和STLport。如果您在尝试关闭警告之前使用STLport,可能值得检查。
#4
add -w to your $CC or whatever var you use.
将-w添加到您的$ CC或您使用的任何变量。
#1
In SunStudio 12, the #pragma error_messages work as documented in the C users manual.
在SunStudio 12中,#pragma error_messages的工作方式如C用户手册中所述。
You can see the tags with the -errtags=yes option, and use it like this:
您可以使用-errtags = yes选项查看标记,并像这样使用它:
// Disable badargtypel2w:
// String literal converted to char* in formal argument
#pragma error_messages (off, badargtypel2w )
and then compile with CC (the C++ compiler).
然后使用CC(C ++编译器)进行编译。
#2
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.
如果你宁愿使用命令行选项而不是#pragmas,一个简单的答案就是你可以在编译行上使用-erroff =%all。
You can suppress specific warning messages with -erroff=%tag
您可以使用-erroff =%标记来禁止特定警告消息
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.
您可以通过在编译行中添加-errtags来打印警告消息的标记。然后,您可以为-erroff定义一组逗号分隔值,仅抑制这些标记。
See http://docs.oracle.com/cd/E19205-01/820-7599/bkapa/index.html for more info.
有关详细信息,请参阅http://docs.oracle.com/cd/E19205-01/820-7599/bkapa/index.html。
Note that Sun Studio 12 update 1 is now available, and I'm referencing the SS12u1 doc here.
请注意,Sun Studio 12更新1现已可用,我在此处引用了SS12u1文档。
#3
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.
无法关闭警告,但是当我上次查看SunStudio时,它附带了两个STL - 一个较旧的STL,用于向后兼容早期的编译器版本和STLport。如果您在尝试关闭警告之前使用STLport,可能值得检查。
#4
add -w to your $CC or whatever var you use.
将-w添加到您的$ CC或您使用的任何变量。