Flatbuffers is an efficient cross platform serialization library for C++, with support for Java and Go. It was created at Google specifically for game development and other performance-critical applications.
Charge a *.fbs file and generate a C++ header
You can check all the flatbuffers examples which are uploaded in biicode and execute any of them. Then, create a new project and open the examples/flatbuffers block.
~$ bii init flatb_sample ~$ cd flatb_sample ~/flatb_sample$ bii open examples/flatbuffers ~/flatb_sample$ bii build
MinGW compiler bug
MinGW users may need to edit io.h to avoid building errors. Look for MinGW/include/io.h and replace lines 301 and 302:
__CRT_INLINE off64_t lseek64 (int, off64_t, int); __CRT_INLINE off64_t lseek64 (int fd, off64_t offset, int whence)
__CRT_INLINE _off64_t lseek64 (int, _off64_t, int); __CRT_INLINE _off64_t lseek64 (int fd, _off64_t offset, int whence)
Now, you can charge the file "monster.fbs" and generate a C++ header for tables/structs:
~/flatb_sample$ cd bin ~/flatb_sample/bin$ examples_flatbuffers_flatc -c ../blocks/examples/flatbuffers/monster.fbs
Now, you'll see one single file "monster_generated.h" in your current folder that has been created correctly.