flatbuffers c++, I wonder if multiple tables in 1 fbs file is possible

854 Views Asked by At

Multiple tables and multiple root_type in 1 fbs file is possible in javascript.

examle::

table Login {
    name:string;
    password:string;
}

table Attack {
    damage:short;
}

2 root_type table was made and 2 getRoot function(getRootAsLogin, getRootAsAttack) was made.

But 1 getRootAs function was made when written in C++ using the same schema.

How do I get two getRootAs function in 1 fbs file? split one file into one table?

1

There are 1 best solutions below

0
On

You can simply use GetRoot<Login>() and GetRoot<Attack>() if you need other roots than what was declared for root_type.

Splitting into 2 files, each with their own root_type declaration, will also work, if you prefer the generated functions.