Qt使用protobuf笔记

194 篇文章 108 订阅

解决使用protobuf库过程中出现的编译问题。protobuf和XML,json一样的数据结构。

插图

问题1

  • 缺protobuf库,可以定义PROTOBUF_USE_DLLS来链接protobuf库。
无法解析的外部符号 "class google::protobuf::internal::ExplicitlyConstructed<class std::basic_string<char,struct std::char_traits,class std::allocator > >
  • 解决方法:
DEFINES += PROTOBUF_USE_DLLS

问题2

  • std::min,std::max与windows.h的min,max冲突了。
.pb.h:189: warning: C4003: 类函数宏的调用“min”参数不足
.pb.h:189: warning: C4003: 类函数宏的调用“max”参数不足
.pb.h:189: error: C2589:(:::”右边的非法标记
UserInfo_STATE_UserInfo_STATE_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits<::google::protobuf::int32>::min(),
UserInfo_STATE_UserInfo_STATE_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits<::google::protobuf::int32>::max()
  • 解决方法:
    屏蔽windows.h的min, max方法
DEFINES += NOMINMAX 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值