From a875d247add6889d405aadf7cc35aae4b26a59eb Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 4 May 2020 21:27:50 +0200 Subject: [PATCH] only add native_include_files if object based api is enabled (#5886) The native include files tag is intended to be used together with the object based api. A client which does not use the object based api should have no need to know about the additional include files needed for the object based api. The generated flatbuffers code without object api enabled should compile without the additional header files. --- src/idl_gen_cpp.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/idl_gen_cpp.cpp b/src/idl_gen_cpp.cpp index 8c6e27c93..7521bf890 100644 --- a/src/idl_gen_cpp.cpp +++ b/src/idl_gen_cpp.cpp @@ -200,10 +200,12 @@ class CppGenerator : public BaseGenerator { void GenIncludeDependencies() { int num_includes = 0; - for (auto it = parser_.native_included_files_.begin(); - it != parser_.native_included_files_.end(); ++it) { - code_ += "#include \"" + *it + "\""; - num_includes++; + if (opts_.generate_object_based_api) { + for (auto it = parser_.native_included_files_.begin(); + it != parser_.native_included_files_.end(); ++it) { + code_ += "#include \"" + *it + "\""; + num_includes++; + } } for (auto it = parser_.included_files_.begin(); it != parser_.included_files_.end(); ++it) {