以下代码不会抑制任何 C4503 编译器警告,但会抑制 C4244 警告。
#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)
请明确解释为什么未抑制 C4503 警告。注意:这可能是由于与 How can I work around warning C4505 in third party libraries? 中引用的类似原因造成的.
我在 Windows 7 机器上使用 Visual Studio 2008。
最佳答案
从上下文看不清楚,但也许你有太多的 #pragma
语句? MSDN 说:
The compiler only supports up to 56 #pragma warning statements in a compiland.
关于c++ - 是否可以禁用编译器警告 C4503?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9673504/