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.
This commit is contained in:
Thomas 2020-05-04 21:27:50 +02:00 committed by GitHub
parent 6e9f5d9810
commit a875d247ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -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) {