以下代码不禁止任何C4503编译器警告,但它确实会抑制C4244警告。是否可以禁用编译器警告C4503?
#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。
没有一些额外的上下文,你禁用警告,有点难以想出一个解决方案。我的猜测:你禁用围绕实例化怪物模板的代码的警告,但是你需要在定义了模板的头部之前禁用该警告。 – Xeo 2012-03-12 19:30:57
@Xeo我再次检查并确认这不是问题。 – 2012-03-12 20:57:32
您应该考虑解决这些警告,因为它们可能会导致问题,例如,链接时。 – PlasmaHH 2012-03-13 21:10:19