Skip to content

Commit

Permalink
moved function to namespace (google#8068)
Browse files Browse the repository at this point in the history
  • Loading branch information
reshilkin authored and Jochen Parmentier committed Oct 29, 2024
1 parent d3ecc54 commit fb187e3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions include/flatbuffers/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,12 @@ namespace flatbuffers {
#define FLATBUFFERS_SUPPRESS_UBSAN(type)
#endif

// This is constexpr function used for checking compile-time constants.
// Avoid `#pragma warning(disable: 4127) // C4127: expression is constant`.
template<typename T> FLATBUFFERS_CONSTEXPR inline bool IsConstTrue(T t) {
return !!t;
namespace flatbuffers {
// This is constexpr function used for checking compile-time constants.
// Avoid `#pragma warning(disable: 4127) // C4127: expression is constant`.
template<typename T> FLATBUFFERS_CONSTEXPR inline bool IsConstTrue(T t) {
return !!t;
}
}

// Enable C++ attribute [[]] if std:c++17 or higher.
Expand Down
2 changes: 1 addition & 1 deletion src/idl_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2118,7 +2118,7 @@ CheckedError Parser::ParseSingleValue(const std::string *name, Value &e,
auto match = false;

#define IF_ECHECK_(force, dtoken, check, req) \
if (!match && ((dtoken) == token_) && ((check) || IsConstTrue(force))) \
if (!match && ((dtoken) == token_) && ((check) || flatbuffers::IsConstTrue(force))) \
ECHECK(TryTypedValue(name, dtoken, check, e, req, &match))
#define TRY_ECHECK(dtoken, check, req) IF_ECHECK_(false, dtoken, check, req)
#define FORCE_ECHECK(dtoken, check, req) IF_ECHECK_(true, dtoken, check, req)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define FLATBUFFERS_NO_FILE_TESTS
#else
#define TEST_OUTPUT_LINE(...) \
do { printf(__VA_ARGS__); printf("\n"); } while(!IsConstTrue(true))
do { printf(__VA_ARGS__); printf("\n"); } while(!flatbuffers::IsConstTrue(true))
#endif

#define TEST_EQ(exp, val) TestEq(exp, val, "'" #exp "' != '" #val "'", __FILE__, __LINE__, "")
Expand Down

0 comments on commit fb187e3

Please sign in to comment.