写了个 a.cpp 文件,编译的时候却报错。
编译:g++ -std=c++ -lprotobuf a.cpp
报错如下:
/usr/local/include/google/protobuf/endian.h: In function ‘uint32_t google::protobuf::internal::big_endian::ToHost(uint32_t)’:
/usr/local/include/google/protobuf/endian.h:174:17: error: conflicting declaration of C function ‘uint32_t google::protobuf::internal::big_endian::ToHost(uint32_t)’
inline uint32_t ToHost(uint32_t value) {
^~~~~~
/usr/local/include/google/protobuf/endian.h:166:17: note: previous declaration ‘uint16_t google::protobuf::internal::big_endian::ToHost(uint16_t)’
inline uint16_t ToHost(uint16_t value) {
但是打开/usr/local/include/google/protobuf/endian.h文件,看166行和174行并不冲突。
166 inline uint16_t ToHost(uint16_t value) {
167 #if defined(PROTOBUF_BIG_ENDIAN)
168 return value;
169 #else
170 return BSwap16(value);
171 #endif
172 }
173
174 inline uint32_t ToHost(uint32_t value) {
175 #if defined(PROTOBUF_BIG_ENDIAN)
176 return value;
177 #else
178 return BSwap32(value);
179 #endif
180 }
你的平台上是不是把 uint16_t 跟 uint32_t 定义成一样的东西了?