1.  命名空间的问题
----------------------------- namespace 1.0.3 版本包含文件类型前面不需要加命名空间,但是1.1.0 中包含需要在类型前加命名空间 include必须放在namespace前面
例如:
include “aa.fbs”
namespace IM.test; foo.fbc
namespace foo;
struct Foo { f: uint; } bar.fbc
include "foo.fbc";
namespace bar;
struct Bar { foo: Foo; } flatc -c bar.fbc will fail with bar.fbc:3:0: error: structs_ may contain only scalar or struct fields 修改方式:
struct Bar { foo: Foo; } -> struct Bar { foo: foo.Foo; } 或者 将 struct 修改成 table struct UserInfo{
user_id:uint;
name:string
} error: structs_ may contain only scalar or struct fields 因为 struct 结构中不能使用 string 类型,修改成 table 即可 2. struct 和 table的区别
------------------------------ http://www.coder4.com/archives/4386
基本类型: 8 bit: byte ubyte bool
16 bit: short ushort
32 bit: int uint float
64 bit: long ulong double 复杂类型: 数组 (用中括号表示 [type]). 不支持嵌套数组,可以用table实现
字符串 string, 支持 UTF-8 或者 7-bit ASCII. 对于其他编码可以用数组 [byte]或者[ubyte]表示。
Struct 只支持基本类型或者嵌套Struct
Table 类似Struct,但是可以支持任何类型。 3. roottype的问题及多个table的解决方式
------------------------------------------ https://github.com/google/flatbuffers/issues/65
Why the need for a Root 1) a commit was pushed yesterday that adds GetRootAs functions for all tables, not just the root_type. 2) generally no. this is a strongly types system, meaning you need to know the kind of buffer you're dealing with. If you want to use this in a context where you want to have multiple different root types, you have these options:
a) make your root type a table that contains a union of all possible sub-roots.
b) prefix flatbuffers with your own file header
c) use flatbuffer's built-in file indentification feature, which hasn't been ported to Java yet. I'll get to that. 3) That's a bug, the 1 should actually read: Any.Monster. I'll fix that. 多个消息一个文件中,但是root_type 只能有一个,解决方式如下:
namespace TestApp; union Msg {TestObj, Hello} struct KV {
key: ulong;
value: double;
} table TestObj {
id:ulong;
name:string;
flag:ubyte = 0;
list:[ulong];
kv:KV;
} table Hello {
id:uint;
name:string;
} table RootMsg{
any:Msg;
} root_type RootMsg; 具体样例可以参见:https://github.com/DavadDi/study_example/tree/master/flatbuffers/multi_table 4. enum不生成name的前缀
--------------------------- flatc -c --no-prefix -b aa.fbs 5. 其他问题
---------------------------- enum的默认值只能从0开始 由于table中的字段全部为可选,因此所有返回指针的地方都必须判断是否为空指针
#define STR(ptr) (ptr!=nullptr)?ptr->c_str():""
std::string = STR(user_info->user_name());

flatbuffers 使用问题记录的更多相关文章

  1. Protocol Buffers与FlatBuffers效率对比

    Protocol Buffers是Google跨语言.跨平台的通用序列化库.FlatBuffers同样出自Google,而且也跨语言跨平台,但更强调效率,专门为游戏开发打造.在游戏界混了几年,各种各样 ...

  2. 在Android中使用FlatBuffers(中篇)

    本文来自网易云社区. FlatBuffers.Protobuf及JSON对比测试 FlatBuffers相对于Protobuf的表现又如何呢?这里我们用数据说话,对比一下FlatBuffers格式.J ...

  3. 在Android中使用FlatBuffers(下篇)

    本文来自网易云社区. FlatBuffers编码数组 编码数组的过程如下: 先执行 startVector(),这个方法会记录数组的长度,处理元素的对齐,准备足够的空间,并设置nested,用于指示记 ...

  4. Flatbuffers学习

    flatbuffers简介 FlatBuffers 是一个(二进制 buffer)序列化开源库,由 Google 开源现在它支持C++, C#, C, Go, Java, Kotlin, JavaSc ...

  5. 记一次debug记录:Uncaught SyntaxError: Unexpected token ILLEGAL

    在使用FIS3搭建项目的时候,遇到了一些问题,这里记录下. 这里是发布搭建代码: // 代码发布时 fis.media('qa') .match('*.{js,css,png}', { useHash ...

  6. nginx配置反向代理或跳转出现400问题处理记录

    午休完上班后,同事说测试站点访问接口出现400 Bad Request  Request Header Or Cookie Too Large提示,心想还好是测试服务器出现问题,影响不大,不过也赶紧上 ...

  7. Kali对wifi的破解记录

    好记性不如烂笔头,记录一下. 我是在淘宝买的拓实N87,Kali可以识别,还行. 操作系统:Kali 开始吧. 查看一下网卡的接口.命令如下 airmon-ng 可以看出接口名称是wlan0mon. ...

  8. 2015 西雅图微软总部MVP峰会记录

    2015 西雅图微软总部MVP峰会记录 今年决定参加微软MVP全球峰会,在出发之前本人就已经写这篇博客,希望将本次会议原汁原味奉献给大家 因为这次是本人第一次写会议记录,写得不好的地方希望各位园友见谅 ...

  9. 分享一个SQLSERVER脚本(计算数据库中各个表的数据量和每行记录所占用空间)

    分享一个SQLSERVER脚本(计算数据库中各个表的数据量和每行记录所占用空间) 很多时候我们都需要计算数据库中各个表的数据量和每行记录所占用空间 这里共享一个脚本 CREATE TABLE #tab ...

随机推荐

  1. 软件测试Lab2

    1.本次上机实验任务:使用webDriver完后自动化测试 2.本次上机实验目的:掌握webDriver的用法和配置. 3.本次上机实验内容: 3.1Selenium的安装: 首先我们上Seleniu ...

  2. saltstack通过salt.client执行命令(转)

    利用saltstack的salt.client模块可以在python的命令行下或者python脚本里执行相应的salt命令 master端想要执行类似 salt '*' cmd.run 'uptime ...

  3. 如何解决ajax跨域问题(转)

    由 于此前很少写前端的代码(哈哈,不合格的程序员啊),最近项目中用到json作为系统间交互的手段,自然就伴随着众多ajax请求,随之而来的就是要解决 ajax的跨域问题.本篇将讲述一个小白从遇到跨域不 ...

  4. Linux下配置PHP开发环境

    转载于: http://www.uxtribe.com/php/405.html 该站下有系列PHP文章. 在Linux下搭建PHP环境比Windows下要复杂得多.除了安装Apache,PHP等软件 ...

  5. UVA 11355 Cool Points(几何)

    Cool Points We have a circle of radius R and several line segments situated within the circumference ...

  6. Java基础の乱弹琴二:break关键字

    Java中的break一般用于 跳出一个switch或者循环. 跳出switch基本不用赘述. break跳出循环一般是跳出当前一层循环. 如若需要跳出多层循环可以在break后加标签,然后把标签标注 ...

  7. Linux学习之一——开机必备知识

    linux最重要的特色是指令交互,利用一个个指令来进行各种操作.当然可以用X Window获得友好的linux窗口,但是还是有很多局限性. linux用户登录后默认进入 /root目录下. 比较重要的 ...

  8. Shell basic1

    A shell script is a text file that typically begins with a shebang, as follows: #!/bin/bash /bin/bas ...

  9. 技巧:利用 Workflow 显示附近的免费 Wi-Fi

    得益于 Workflow 自 1.5.3 版本起更新的 Get Content of URL 动作,该 App 的潜力得到了极大的提升.本文分享一种有趣的用法,搜寻附近的免费 Wi-Fi 并择一显示在 ...

  10. TestNG之执行测试类方式

    TestNG提供了很多执行方式,下面做简单介绍. 1.XML指明测试类,按照类名执行,其中可以指定包名,也可指定无包名: 带包名,运行ParameterSample类和ParameterTest类 & ...