环境: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。我尝试过的其他东西:
- 将带有'//mark'的行作为应用程序的最后一行,没有效果。
- 如果我在没有推送/弹出的情况下使用#pragma 警告(禁用:4503 4702),它可以工作,但它会影响之后为整个解决方案编译的内容,即使我将#pragma 警告(默认值:xx)放在某处,它似乎也没有将警告设置回默认状态。
谁知道为什么会发生这种情况以及在 Visual Studio 中抑制警告的最佳解决方案是什么。干杯。