是否可以关闭编译器警告?

Is it possible to turn off compiler warnings?

如果我选择 级别警告(全部) /墙

Studio 显示来自此文件的许多警告:

wchar.h
math.h
xmemory0
xstring

示例:

代码:

std::cout << "\n\n";

编译器:

ios(116): 警告 C4710: std::string std::_Generic_error_category::message(int) const:

也许有一些宏,像这样的?

#define start_warnings
#undef start_warnings

In Visual Studio /Wall 启用一些非常模糊的警告。它们可能很有用,例如使用填充字节定位结构,但通常是矫枉过正,并且系统 headers 并未设计为此级别的 warning-free。请改用 /W4

如果确实需要调整级别或 enable/disable 特定警告,请参阅 #pragma warning