STL VS13 C++:错误C4996未禁用
STL VS13 C++: Error C4996 not disabling
我在VS13:中有这个代码
double distance(vector <double> point) {
return sqrt(inner_product(point[0], point[4], point, 0));
}
int main() {
vector < double > point {2, 2, 2, 2};
cout << distance(point);
cin.get();
}
它调用
error C4996 ('std::_Inner_product2': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS)
c:program filesmicrosoft visual studio 12.0vcincludexutility(372): error C2825: '_Iter': must be a class or namespace when followed by '::'
c:program filesmicrosoft visual studio 12.0vcincludexutility(372): error C2039: 'value_type' : is not a member of '`global namespace''
c:program filesmicrosoft visual studio 12.0vcincludexutility(372): error C2146: syntax error : missing ';' before identifier 'value_type'
c:program filesmicrosoft visual studio 12.0vcincludexutility(372): error C2602: 'std::iterator_traits<_InIt>::value_type' is not a member of a base class of 'std::iterator_traits<_InIt>'
我知道这里有很多类似的问题。我还阅读了MSDN上的文档。
因此,我尝试了下一个解决方案:
1) #define _SCL_SECURE_NO_WARNINGS
从过去的评论来看,它似乎有效,但对我来说,它导致了一大堆错误,比如:
c:program filesmicrosoft visual studio 12.0vcincludexutility(371): error C2825: '_Iter': must be a class or namespace when followed by '::'
2)
#pragma warning(disable:4996)
#pragma warning(default:4996)
造成了同样的错误;
3) 项目属性->配置属性->C/C++->常规->SDL检查->编号
就是不起作用。
你能看一看并写下我如何禁用那个错误吗?谢谢
我想你指的是以下函数
double distance( const std::vector<double> &point )
{
return std::sqrt( std::inner_product( point.begin(), point.end(), point.begin(), 0.0 ) );
}
这是一个演示程序
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>
double distance( const std::vector<double> &point )
{
return std::sqrt( std::inner_product( point.begin(), point.end(), point.begin(), 0.0 ) );
}
int main()
{
std::vector<double> point = { 2, 2, 2, 2 };
std::cout << distance( point ) << std::endl;
}
输出为
4
工具选项高级
这里有一个部分用于抑制警告
如果我没有记错4820;4996;4710是我一直压制的三个。
相关文章:
- 警告处理为错误这里有什么问题
- "error: no matching function for call to"构造函数错误
- boost::进程间消息队列引发错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- QT在错误的班级中寻找空位
- 冲刺错误"variable may be unsafe" (C4996)...选择?
- 视觉"如何修复错误 C4996:"_strupr":C++ 中的错误"
- [[弃用]]导致VS2017(错误C4996)中的构建故障
- STL VS13 C++:错误C4996未禁用
- Visual Studio 2015 错误 C4996"std::_Copy_impl":使用可能不安全的参数进行函数调用
- 错误 C4996:"std::_Copy_impl":使用可能不安全的参数进行函数调用
- 使用C++strtk会导致一个xutility错误C4996
- OpenCL编译错误C4996
- C4018,错误C4996和错误C4716 c++
- 错误C4996使用boost的例子
- 错误 C4996 C++客户端和服务器
- 错误 C4996 'fopen'未声明
- Visual Studio 2015 不会禁止显示错误 C4996
- 错误 C4996:"std::_Copy_impl":禁用它是否安全?