Closed mzygQAQ closed 3 years ago
// Generated by the protocol buffer compiler. DO NOT EDIT! // source: proto/IM_UserModule.proto
// @@protoc_insertion_point(includes)
look at the code generate by protoc , why the #include <google/protobuf/port_def.inc> in a file twice , this file is not guard by #ifndef xxx or #pagram once
Including port_def.inc
multiple times is ok as long as port_def.inc
and port_undef.inc
are balanced.
In your code sample, they are indeed balanced (port_undef.inc
is included before we include port_def.inc
again), so this is not a codegen bug.
Instead it looks like a bug in port_undef.inc
, that it is not #undef
ing these symbols.
You just need regenerate the protobuf-autogen files BY
protoc --cpp_out=./ your.proto
Including
port_def.inc
multiple times is ok as long asport_def.inc
andport_undef.inc
are balanced.In your code sample, they are indeed balanced (
port_undef.inc
is included before we includeport_def.inc
again), so this is not a codegen bug.Instead it looks like a bug in
port_undef.inc
, that it is not#undef
ing these symbols.
This explanation was helpful; thank you.
Here are the error infos: It seems to be that the port_def.h was included more than once.
g++ src/main.cpp src/user/IM_UserModule.pb.cc -o imServer -I /usr/local/include -L /usr/local/lib -lprotobuf In file included from src/main.cpp:1: In file included from src/user/IM_UserModule.pb.h:22: In file included from /usr/local/include/google/protobuf/arena.h:55: In file included from /usr/local/include/google/protobuf/arena_impl.h:39: In file included from /usr/local/include/google/protobuf/stubs/common.h:46: In file included from /usr/local/include/google/protobuf/stubs/macros.h:34: In file included from /usr/local/include/google/protobuf/stubs/port.h:43: /usr/local/include/google/protobuf/port_def.inc:56:2: error: PROTOBUF_NAMESPACE was previously defined
error PROTOBUF_NAMESPACE was previously defined
^ /usr/local/include/google/protobuf/port_def.inc:59:2: error: PROTOBUF_NAMESPACE_ID was previously defined
error PROTOBUF_NAMESPACE_ID was previously defined
^ /usr/local/include/google/protobuf/port_def.inc:62:2: error: PROTOBUF_ALWAYS_INLINE was previously defined
error PROTOBUF_ALWAYS_INLINE was previously defined
^ /usr/local/include/google/protobuf/port_def.inc:65:2: error: PROTOBUF_COLD was previously defined
error PROTOBUF_COLD was previously defined
^ /usr/local/include/google/protobuf/port_def.inc:68:2: error: PROTOBUF_NOINLINE was previously defined