From e597ad8f0f63bd0e5b9571e7c6c9d22d3e1acdc5 Mon Sep 17 00:00:00 2001 From: Wouter van Oortmerssen Date: Mon, 11 Apr 2016 11:05:42 -0700 Subject: [PATCH] Fixed pre-declarations of included types in generated code. This was harmless, but unnecessary. Change-Id: I1365a725e254d4ebbda081110a50277cb5118323 Tested: on Linux. --- src/idl_gen_cpp.cpp | 6 ++++-- tests/monster_test_generated.h | 8 -------- 2 files changed, 4 insertions(+), 10 deletions(-) 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 {