对于一个简单的原型文件:
message Person { required int32 id = 1; required string name = 2; optional string email = 3; }
它已经被编译并protoc.exe结果在还简单的测试项目,基本上没有什么,但包括protoc生成的文件中。
我使用的是msvc10建立测试项目(64位),然后给了我很多的警告:
Warning 1 warning C4244: 'return' : conversion from '__int64' to 'int', possible loss of data D:\Work\protobuf-trunk\src\google\protobuf\descriptor.h 1441 1 testProtobuf ... Warning 11 warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data D:\Work\protobuf-trunk\src\google\protobuf\unknown_field_set.h 142 1 testProtobuf Warning 12 warning C4267: 'return' : conversion from 'size_t' to 'int', possible loss of data D:\Work\protobuf-trunk\src\google\protobuf\unknown_field_set.h 237 1 testProtobuf ... Warning 14 warning C4244: '=' : conversion from '__int64' to 'int', possible loss of data D:\Work\protobuf-trunk\src\google\protobuf\io\coded_stream.h 902 1 testProtobuf Warning 15 warning C4244: 'return' : conversion from '__int64' to 'int', possible loss of data D:\Work\protobuf-trunk\src\google\protobuf\io\coded_stream.h 1078 1 testProtobuf Warning 16 warning C4267: 'argument' : conversion from 'size_t' to 'google::protobuf::uint32', possible loss of data D:\Work\protobuf-trunk\src\google\protobuf\wire_format_lite_inl.h 663 1 testProtobuf ... Warning 19 warning C4267: 'return' : conversion from 'size_t' to 'int', possible loss of data D:\Work\protobuf-trunk\src\google\protobuf\wire_format_lite_inl.h 739 1 testProtobuf Warning 20 warning C4267: 'argument' : conversion from 'size_t' to 'google::protobuf::uint32', possible loss of data D:\Work\protobuf-trunk\src\google\protobuf\wire_format_lite_inl.h 742 1 testProtobuf Warning 21 warning C4267: 'return' : conversion from 'size_t' to 'int', possible loss of data D:\Work\protobuf-trunk\src\google\protobuf\wire_format_lite_inl.h 743 1 testProtobuf Warning 22 warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data D:\Work\testProtobuf\testProtobuf\person.pb.cc 211 1 testProtobuf ... Warning 28 warning 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 10.0\VC\include\xutility 2239 1 testProtobuf Warning 29 warning 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 10.0\VC\include\xutility 2239 1 testProtobuf
有没有办法解决所有这些警告什么好办法? 任何建议将不胜感激。
PS。 该libprotobuf项目本身可以通过清洁msvc10没有任何警告编译。
[ 编辑2013年2月20日 ]
工作液:
- 对于那些protoc产生.cc的文件,设置属性:
配置属性 - > C / C ++ - >高级 - >禁用特定警告