From f5e343efba69c3cac4d03155eb411f20c74f1366 Mon Sep 17 00:00:00 2001 From: Wouter van Oortmerssen Date: Fri, 5 Sep 2014 10:56:16 -0700 Subject: [PATCH] A generated C++ function was missing "inline". This would cause double definition linker errors when included in multiple compilation units. Change-Id: Ie6fd4af018055a099343182a92a7776f2fea4725 Tested: on Linux. --- src/idl_gen_cpp.cpp | 2 +- tests/monster_test_generated.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/idl_gen_cpp.cpp b/src/idl_gen_cpp.cpp index 1aeff87d6..ba07194cd 100644 --- a/src/idl_gen_cpp.cpp +++ b/src/idl_gen_cpp.cpp @@ -165,7 +165,7 @@ static void GenEnum(EnumDef &enum_def, std::string *code_ptr, // verifier function to call, this should be safe even if the union type // has been corrupted, since the verifiers will simply fail when called // on the wrong type. - auto signature = "bool Verify" + enum_def.name + + auto signature = "inline bool Verify" + enum_def.name + "(flatbuffers::Verifier &verifier, " + "const void *union_obj, uint8_t type)"; code += signature + ";\n\n"; diff --git a/tests/monster_test_generated.h b/tests/monster_test_generated.h index 8c45a40b7..a3e138b8c 100755 --- a/tests/monster_test_generated.h +++ b/tests/monster_test_generated.h @@ -43,7 +43,7 @@ inline const char **EnumNamesAny() { inline const char *EnumNameAny(int e) { return EnumNamesAny()[e]; } -bool VerifyAny(flatbuffers::Verifier &verifier, const void *union_obj, uint8_t type); +inline bool VerifyAny(flatbuffers::Verifier &verifier, const void *union_obj, uint8_t type); MANUALLY_ALIGNED_STRUCT(2) Test { private: @@ -188,7 +188,7 @@ inline flatbuffers::Offset CreateMonster(flatbuffers::FlatBufferBuilder return builder_.Finish(); } -bool VerifyAny(flatbuffers::Verifier &verifier, const void *union_obj, uint8_t type) { +inline bool VerifyAny(flatbuffers::Verifier &verifier, const void *union_obj, uint8_t type) { switch (type) { case Any_NONE: return true; case Any_Monster: return verifier.VerifyTable(reinterpret_cast(union_obj));