proto文件:
syntax = "proto3";
package Im;
message Content
{
int32 id = 1;
string str = 2;
optional int32 opt = 3;
}
编译语句:
protoc ./Mymessage.proto --cpp_out=./test
proto文件:
syntax = "proto3";
package Im;
message Content
{
int32 id = 1;
string str = 2;
optional int32 opt = 3;
}
编译语句:
protoc ./Mymessage.proto --cpp_out=./test
你不用管它,直接编译看能不能通过,能通过就说明没有问题。
不能通过的话,在.h 文件的 文件包含(include) 后面加上这个:
#define PROTOBUF_NAMESPACE_OPEN \
namespace google \
{ \
namespace protobuf \
{
#define PROTOBUF_NAMESPACE_CLOSE \
} \
}
#define PROTOBUF_NAMESPACE_ID google::protobuf
#define PROTOBUF_CONSTEXPR
#define PROTOBUF_ATTRIBUTE_REINITIALIZES
#define PROTOBUF_NODISCARD [[nodiscard]]
#define PROTOBUF_ALWAYS_INLINE
using namespace google;