为空 main() 生成警告

Warning generated for empty main()

我在 VS 2015 上创建了一个默认的空项目并将警告设置为 /Wall。我有一个包含以下内容的源文件:

#pragma warning(push, 3)        
#include <functional>
#pragma warning(pop)

//#pragma warning( disable : 4710 )
int main()
{

}

我收到以下错误:

1>c:\users\flatmouse\documents\visual studio 2015\projects\project72\project72\source.cpp(10): warning C4710: 'std::exception_ptr std::exception_ptr::_Current_exception(void) throw()': function not inlined
1>  c:\program files (x86)\microsoft visual studio 14.0\vc\include\exception(299): note: see declaration of 'std::exception_ptr::_Current_exception'
1>c:\users\flatmouse\documents\visual studio 2015\projects\project72\project72\source.cpp(10): warning C4710: 'std::exception_ptr std::current_exception(void) noexcept': function not inlined
1>  c:\program files (x86)\microsoft visual studio 14.0\vc\include\exception(358): note: see declaration of 'std::current_exception'

接下来我尝试通过将 pop 移动到最后一行来将所有源代码的警告级别保持在 3:

#pragma warning(push, 3)        
#include <functional>

//#pragma warning( disable : 4710 )
int main()
{

}
#pragma warning(pop)

但我仍然遇到同样的错误。

为什么还是报警告?

对于 Visual C++,使用 /W4,而不是 /Wall。后者只是要求大量愚蠢的警告。过去,/W4 会为 Windows API 和 C++ 标准库 headers 提供大量警告,但令人高兴的是,Visual C++ 2015 不再如此。