error C4996: Function call with parameters that may be unsafe – this call relies on the caller to ch

来源:互联网 发布:网络空间拟态防御 编辑:程序博客网 时间:2024/05/17 02:32

最近深入C++标准库,使用VS2013编译一个例子的时候报错

错误 1 error C4996: 'std::_Transform1': 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. See documentation on how to use Visual C++ 'Checked Iterators' \microsoft visual studio 12.0\vc\include\algorithm 1026 1 ContCArray

看来微软对transform这类标准库函数还真是毫不留情呢,那就入乡随俗,禁用这个错误吧,在文件头加一句#pragma warning(disable : 4996)就可以了。注意#pragma warning(disable : 4996)只对当前文件(包括包含了当前文件的文件)起作用,并非对整个工程。

方法二:如果你确定逻辑是对的,只要在文件里开头写#define _SCL_SECURE_NO_WARNINGS 就好

0 0