我使用 VC++ 2013,我有以下代码:
#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
如果你使用自制迭代器那么typedef 迭代器_Unchecked_type;在自定义迭代器内部,使 microsoft std 库信任它已被检查。
class iterator: public std::iterator<std::input_iterator_tag, const uint8_t>
{
public:
typedef iterator _Unchecked_type;
// your implementation here
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)