windows下OpenCV的两个常见报错项flann\saving.h error C4996
报错内容如下,
D:\OpenCV412\opencv-4.1.2\modules\flann\include\opencv2\flann\saving.h(101,1): error C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
遵守microsoft的安全规则,我一般项目中都不使用_CRT_SECURE_NO_WARNINGS,所以改原码,每次都改同样的地方,这次记录下,方便下次快速定位
在文件的第90行和92行,把
strcpy(header.signature, FLANN_SIGNATURE_);
strcpy(header.version, FLANN_VERSION_);
修改成
strcpy_s(header.signature, 16, FLANN_SIGNATURE_);
strcpy_s(header.version, 16, FLANN_VERSION_);
template<typename Distance> void save_header(FILE* stream, const NNIndex<Distance>& index) { IndexHeader header; memset(header.signature, 0, sizeof(header.signature)); strcpy_s(header.signature, 16, FLANN_SIGNATURE_); memset(header.version, 0, sizeof(header.version)); strcpy_s(header.version, 16, FLANN_VERSION_); header.data_type = Datatype<typename Distance::ElementType>::type(); header.index_type = index.getType(); header.rows = index.size(); header.cols = index.veclen(); std::fwrite(&header, sizeof(header),1,stream); }