【发布时间】:2019-08-06 06:00:13
【问题描述】:
我有一个平面缓冲区架构文件:
namespace market;
enum MessageType : ubyte {
Null = 0,
MarketDate = 1,
MarketInfo,
}
table MarketDate {
date : string;
}
table MarketInfo {
marketID : string;
marketName : string;
marketType : byte;
}
union MessageData {
marketDate : MarketDate,
marketInfo : MarketInfo,
}
table Message {
type : MessageType;
data : MessageData;
}
root_type Message;
当我为 c++ 生成访问文件时,使用
flatc -c --scoped-enums market.fbs
输出没有任何代码来构造和存储MessageData,它只生成一个枚举。生成的market_generated.h 位于http://sprunge.us/lTfX0H。
我从互联网上读到 union 至少会产生类似:struct MessageDataUnion 和 createMessageDataDirect 或类似的东西,但在我的情况下它不会产生类似的东西,我的代码有什么问题吗?
【问题讨论】:
标签: c++ c++11 serialization union flatbuffers