问题遇到的现象和发生背景
最近赶鸭子上架了解protobuf,使用中遇到异常报错,我感觉是那里写的不对,但排查没有思路
问题相关代码,请勿粘贴截图
test.proto
syntax = "proto3";
package IM;
message Account {
//账号
uint64 ID = 1;
//名字
string name = 2;
//密码
string password = 3;
}
demo.cpp
IM::Account AC;
AC.set_id(20);
char aa[10] = "cc";
AC.set_name(&aa[0]);
//AC.set_password("word");
google::protobuf::ShutdownProtobufLibrary();
我是在qt中测试使用的,lib库和google的src下的头文件都包含了,只设置ID字段没问题,设置name字段就报错
运行结果及报错内容
指向了google下的arenstring.h里的set
err:
Exception at 0x7ffdde524f69, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) in libprotobuf!google::protobuf::UInt32Value::_InternalSerialize