シンプルな proto ファイルの場合:
メッセージ 人物 { 必要な int32 id = 1; 必要な文字列名 = 2; オプションの文字列 email = 3; }
これは protoc.exe によってコンパイルされ、その結果は単純なテスト プロジェクトでも使用されます。このテスト プロジェクトは、基本的に、protoc によって生成されたファイルを含めること以外は何もしません。
msvc10 を使用してテスト プロジェクト (x64) をビルドすると、多くの警告が表示されました。
警告 1 警告 C4244: 'return': '__int64' から 'int' への変換、データが失われる可能性があります D:\Work\protobuf-trunk\src\google\protobuf\descriptor.h 1441 1 testProtobuf ... 警告 11 警告 C4267: 'argument': 'size_t' から 'int' への変換、データが失われる可能性があります D:\Work\protobuf-trunk\src\google\protobuf\unknown_field_set.h 142 1 testProtobuf 警告 12 警告 C4267: 'return': 'size_t' から 'int' への変換、データが失われる可能性があります D:\Work\protobuf-trunk\src\google\protobuf\unknown_field_set.h 237 1 testProtobuf ... 警告 14 警告 C4244: '=': '__int64' から 'int' への変換、データが失われる可能性があります D:\Work\protobuf-trunk\src\google\protobuf\io\coded_stream.h 902 1 testProtobuf 警告 15 警告 C4244: 'return': '__int64' から 'int' への変換、データが失われる可能性があります D:\Work\protobuf-trunk\src\google\protobuf\io\coded_stream.h 1078 1 testProtobuf 警告 16 警告 C4267: '引数': 'size_t' から 'google::protobuf::uint32' への変換、データ D:\Work\protobuf-trunk\src\google\protobuf\wire_format_lite_inl.h 663 1 testProtobuf の損失の可能性 ... 警告 19 警告 C4267: 'return': 'size_t' から 'int' への変換、データが失われる可能性があります D:\Work\protobuf-trunk\src\google\protobuf\wire_format_lite_inl.h 739 1 testProtobuf 警告 20 警告 C4267: '引数': 'size_t' から 'google::protobuf::uint32' への変換、データ D:\Work\protobuf-trunk\src\google\protobuf\wire_format_lite_inl.h 742 1 testProtobuf の損失の可能性 警告 21 警告 C4267: 'return': 'size_t' から 'int' への変換、データが失われる可能性があります D:\Work\protobuf-trunk\src\google\protobuf\wire_format_lite_inl.h 743 1 testProtobuf 警告 22 警告 C4267: 'argument': 'size_t' から 'int' への変換、データが失われる可能性があります D:\Work\testProtobuf\testProtobuf\person.pb.cc 211 1 testProtobuf ... 警告 28 警告 C4996: 'std::_Copy_impl': 安全でない可能性のあるパラメーターを使用した関数呼び出し - この呼び出しは、渡された値が正しいことを確認するために呼び出し元に依存しています。この警告を無効にするには、-D_SCL_SECURE_NO_WARNINGS を使用します。Visual C++ 'Checked Iterators' C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xutility 2239 1 testProtobuf の使用方法に関するドキュメントを参照してください。 警告 29 警告 C4996: 'std::_Copy_impl': 安全でない可能性のあるパラメーターを使用した関数呼び出し - この呼び出しは、渡された値が正しいことを確認するために呼び出し元に依存しています。この警告を無効にするには、-D_SCL_SECURE_NO_WARNINGS を使用します。Visual C++ 'Checked Iterators' C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xutility 2239 1 testProtobuf の使用方法に関するドキュメントを参照してください。
これらすべての警告に対処する良い方法はありますか? どんな提案でも大歓迎です。
ps。libprotobuf プロジェクト自体は、警告なしで msvc10 によってクリーン コンパイルできます。
[編集 2013/02/20 ]
作業ソリューション:
- protoc で生成された .cc ファイルのプロパティを設定します:
構成プロパティ -> c/c++ -> 高度な設定 -> 特定の警告を無効にする