Is it possible to disable compiler warning C4503?

主宰稳场 提交于 2019-12-10 03:49:21

问题


The following code does NOT suppress ANY C4503 compiler warnings, but it does suppress C4244 warnings.

#pragma warning(push)
#pragma warning(disable:4503)
#pragma warning(disable:4244)

#include <map>
#include <string>

int main(int argc, char *argv[])
{
    class Field;
    typedef std::map<std::string, Field * > Screen;
    typedef std::map<std::string, Screen> WebApp;
    typedef std::map<std::string, WebApp> WebAppTest;
    typedef std::map<std::string, WebAppTest> Hello;
    Hello MyWAT; // The C4503 error is NOT suppressed

    int a;
    a = 5.0f; // The C4244 error is suppressed
}

#pragma warning(pop)

Please definitively explain why C4503 warnings are not suppressed. Note: it might be due to a similar reason as referenced in How can I work around warning C4505 in third party libraries?.

See this and this for more relevant infornation.

I'm using Visual Studio 2008 on a Windows 7 machine.


回答1:


Not clear from the context, but maybe you have too many #pragma statements? MSDN says:

 The compiler only supports up to 56 #pragma warning statements in a compiland.



回答2:


Bit weird but you can disable this warning using your exact code just by removing the #pragma warning(pop). I don't understand why though.

I should say I'm on VS2010 C++ Express edition.




回答3:


Maybe stating the obvious but you can use the IDE settings to remove this (and other) warning(s) entirely, as explained here.

That was the only solution that worked for me, and was justified after learning that Boost has warning enable/disable policies built within, which alter the behavior of #pragma push/pop/enable/disable statements.



来源:https://stackoverflow.com/questions/9673504/is-it-possible-to-disable-compiler-warning-c4503

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!