禁用Visual Studio 2008中的警告

4

环境:Visual Studio警告级别设置为4, 代码位于解决方案中唯一的文件中:

#pragma warning( push )
#pragma warning( disable: 4503 )
#pragma warning( disable: 4702 )
#include <boost/property_tree/ptree.hpp>
#pragma warning ( pop ) //mark

#include "iostream"

int main()
{
boost::property_tree::ptree pt;
for( boost::property_tree::ptree::const_iterator it = pt.begin();
     it != pt.end();
     ++it )
    {
    std::cout << it->second.data() << '\n';
    }

return 0;
}

问题:编译时仍然出现警告4503。 我尝试了以下方法:
  1. 将带有“//mark”的行作为应用程序的最后一行,但没有效果。
  2. 如果我使用#pragma warning(disable: 4503 4702)而不是push/pop,则可以解决问题,但它会影响整个解决方案后续编译的内容,即使我在某个地方放置#pragma warning(default: xx),似乎也无法将警告设置回默认状态。
谁知道为什么会发生这种情况,以及在Visual Studio中抑制警告的最佳解决方案。谢谢。
1个回答

2

但它没有解释为什么替代方案1不起作用。 - JQ.

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接