Are there some better ways to address warnings when compiling protocol buffer generated source file?

后端 未结 3 1018
长发绾君心
长发绾君心 2021-01-11 09:52

For a simple proto file:

message Person {
  required int32 id = 1;
  required string name = 2;
  optional string email = 3;
}

It\'s been compiled by pr

3条回答
  •  醉酒成梦
    2021-01-11 10:07

    A simple approach is to use a wrapper header for including the generated protobuf headers:

    #ifndef MESSAGES_WRAPPER_H
    #define MESSAGES_WRAPPER_H
    
    #ifdef _MSC_VER
      #pragma warning(push)
      #pragma warning(disable: 4018 4100 4267)
    #endif
    
    #include "messages.pb.h"
    
    #ifdef _MSC_VER
      #pragma warning(pop)
    #endif
    
    #endif // MESSAGES_WRAPPER_H
    

提交回复
热议问题