diff --git a/src/idl_gen_cpp.cpp b/src/idl_gen_cpp.cpp index cae3812db..e043b0146 100644 --- a/src/idl_gen_cpp.cpp +++ b/src/idl_gen_cpp.cpp @@ -777,8 +777,10 @@ std::string GenerateCPP(const Parser &parser, for (auto it = parser.structs_.vec.begin(); it != parser.structs_.vec.end(); ++it) { auto &struct_def = **it; - CheckNameSpace(struct_def, &code); - code += "struct " + struct_def.name + ";\n\n"; + if (!struct_def.generated) { + CheckNameSpace(struct_def, &code); + code += "struct " + struct_def.name + ";\n\n"; + } } // Generate code for all the enum declarations. diff --git a/tests/monster_test_generated.h b/tests/monster_test_generated.h index a7f02ffe7..ef7f577f5 100644 --- a/tests/monster_test_generated.h +++ b/tests/monster_test_generated.h @@ -5,14 +5,6 @@ #include "flatbuffers/flatbuffers.h" -namespace MyGame { -namespace OtherNameSpace { - -struct Unused; - -} // namespace OtherNameSpace -} // namespace MyGame - namespace MyGame { namespace Example {