Disallowed 0 byte structs.

This is because they are incompatible with C++ and possibly other
languages that make them minimum size 1 (to make sure multiple
such objects don't reside at the same address). Forcing them to size
1 was also not practical, as that is requires updating the logic
of a lot of implementations and thus possibly backwards incompatible.

More here: https://github.com/google/flatbuffers/issues/4122

Change-Id: I2bfdc8597b7cfd2235bb4074bb2ae06f81f8e57d
This commit is contained in:
Wouter van Oortmerssen
2018-10-29 17:40:19 -07:00
parent 705577de51
commit 160e8f2fdc
8 changed files with 19 additions and 14 deletions

View File

@@ -5,7 +5,7 @@ namespace MyGame.OtherNameSpace;
enum FromInclude:long { IncludeVal }
struct Unused {}
struct Unused { a:int; }
table TableB {
a:TableA;

Binary file not shown.

Binary file not shown.

View File

@@ -16,6 +16,7 @@
"MyGame_OtherNameSpace_Unused" : {
"type" : "object",
"properties" : {
"a" : { "type" : "number" }
},
"additionalProperties" : false
},

View File

@@ -1230,6 +1230,7 @@ void ErrorTest() {
TestError("enum X:byte (bit_flags) { Y=8 }", "bit flag out");
TestError("table X { Y:int; } table X {", "datatype already");
TestError("struct X (force_align: 7) { Y:int; }", "force_align");
TestError("struct X {}", "size 0");
TestError("{}", "no root");
TestError("table X { Y:byte; } root_type X; { Y:1 } { Y:1 }", "end of file");
TestError("table X { Y:byte; } root_type X; { Y:1 } table Y{ Z:int }",