protobuf 提示冲突问题 error: conflicting declaration of C function?

写了个 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 }
阅读 5.9k
2 个回答

你的平台上是不是把 uint16_t 跟 uint32_t 定义成一样的东西了?

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题