错误c4996检查迭代器 [英] Error c4996 Checked Iterators

查看:239
本文介绍了错误c4996检查迭代器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用VC ++ 2013,我有一个下面的代码:

I use VC++ 2013 and I have a following code:

#pragma warning(disable:4996)
#define D_SCL_SECURE_NO_WARNINGS

#include <iostream>
#include <fstream>
#include <object.pb.h>

using namespace std;

int main(int argc, char** argv)
{
    Object object;
    object.set_id(1);
    object.set_name("Ermolaev Ivan");
    object.set_vertex(300.0f);
    fstream output("myfile", ios::out | ios::binary);
    object.SerializeToOstream(&output);
    return 0x0;
}

但后续错误继续显示。

Error   1   error C4996: 'std::_Copy_impl': 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'   c:\program files (x86)\microsoft visual studio 12.0\vc\include\xutility 2132    1   ProtobufTest


推荐答案

D 前缀不是必需的,

您应该将它定义为 _SCL_SECURE_NO_WARNINGS 。最好在 Project Properties - > C ++ - >预处理程序,以使其在所有代码中保持一致。

You should define this as simply _SCL_SECURE_NO_WARNINGS. It's best to do this in Project Properties -> C++ -> Preprocessor, to have it consistent across all your code.

这篇关于错误c4996检查迭代器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆