Gibt es bessere Möglichkeiten, um Warnungen beim Kompilieren der vom Protokollpuffer generierten Quelldatei zu beheben?
Für eine einfache Protodatei:
message Person { required int32 id = 1; required string name = 2; optional string email = 3; }
Es wurde von protoc.exe kompiliert und die Ergebnisse werden in einem ebenfalls einfachen Testprojekt verwendet, das im Grunde nichts anderes tut, als die von protoc generierten Dateien einzuschließen.
Ich benutze die msvc10, um das Testprojekt (x64) zu erstellen, dann gab es mir eine Menge Warnung:
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
Gibt es eine gute Möglichkeit, all diese Warnungen anzusprechen? Vorschläge werden sehr geschätzt.
ps. Das libprotobuf-Projekt selbst kann von msvc10 ohne Vorwarnung sauber kompiliert werden.
[bearbeiten 2013/02/20]
funktionierende Lösung:
Eigenschaften für die von Protoc generierten .cc-Dateien festlegen:Konfigurationseigenschaften -> c / c ++ -> Erweitert -> Bestimmte Warnungen deaktivieren