今天使用PCL1.8.0编译官方教程中“平面提取”例子时,出现下列错误:
error C4996: 'pcl::SAC_SAMPLE_SIZE': This map is deprecated and is kept only to prevent breaking existing user code. Starting from PCL 1.8.0 model sample size is a protected member of the SampleConsensusModel class
1
解决方法
打开项目属性页>C/C++>常规>SDL检查(设置为否)。
重新编译,原先的错误信息变成了警告。
若上面的方法无法解决这个错误,可以打开头文件”model_types.h”,修改其中的代码:
源码:
namespace pcl
{
const static std::map<pcl::SacModel, unsigned int>
PCL_DEPRECATED("This map is deprecated and is kept only to prevent breaking "
"existing user code. Starting from PCL 1.8.0 model sample size "
"is a protected member of the SampleConsensusModel class")
SAC_SAMPLE_SIZE (sample_size_pairs, sample_size_pairs + sizeof (sample_size_pairs) / sizeof (SampleSizeModel));
}
修改后:
namespace pcl
{
const static std::map<pcl::SacModel, unsigned int>
//PCL_DEPRECATED("This map is deprecated and is kept only to prevent breaking "
//"existing user code. Starting from PCL 1.8.0 model sample size "
//"is a protected member of the SampleConsensusModel class")
SAC_SAMPLE_SIZE (sample_size_pairs, sample_size_pairs + sizeof (sample_size_pairs) / sizeof (SampleSizeModel));
}
重新编译即可解决问题。
参考文献:https://blog.csdn.net/wokaowokaowokao12345/article/details/51287011