From baddf905999b23d4dce04812ca9593d260890200 Mon Sep 17 00:00:00 2001 From: Marcin Lewandowski Date: Tue, 20 Aug 2024 00:51:15 +0100 Subject: [PATCH] Add parentheses in FLATBUFFERS_MAX_BUFFER_SIZE, FLATBUFFERS_MAX_64_BUFFER_SIZE to avoid preprocessor definition collision (#8377) In case when flatbuffers are being used along with other project that defines "max" preprocessor macro, the ::max() in FLATBUFFERS_MAX_BUFFER_SIZE and FLATBUFFERS_MAX_64_BUFFER_SIZE is incorrectly being expanded to the macro. Adding parentheses enforces function-like interpretation. Co-authored-by: Derek Bailey --- include/flatbuffers/base.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/flatbuffers/base.h b/include/flatbuffers/base.h index 1a2e1208e..f8ba195f5 100644 --- a/include/flatbuffers/base.h +++ b/include/flatbuffers/base.h @@ -339,8 +339,8 @@ typedef uint16_t voffset_t; typedef uintmax_t largest_scalar_t; // In 32bits, this evaluates to 2GB - 1 -#define FLATBUFFERS_MAX_BUFFER_SIZE std::numeric_limits<::flatbuffers::soffset_t>::max() -#define FLATBUFFERS_MAX_64_BUFFER_SIZE std::numeric_limits<::flatbuffers::soffset64_t>::max() +#define FLATBUFFERS_MAX_BUFFER_SIZE (std::numeric_limits<::flatbuffers::soffset_t>::max)() +#define FLATBUFFERS_MAX_64_BUFFER_SIZE (std::numeric_limits<::flatbuffers::soffset64_t>::max)() // The minimum size buffer that can be a valid flatbuffer. // Includes the offset to the root table (uoffset_t), the offset to the vtable