From 98d79b5973cde5cda1f04c34868ef7788e871b77 Mon Sep 17 00:00:00 2001 From: Marcin Lewandowski Date: Mon, 19 Aug 2024 13:58:30 +0200 Subject: [PATCH] Add parentheses in FLATBUFFERS_MAX_BUFFER_SIZE, FLATBUFFERS_MAX_64_BUFFER_SIZE to avoid preprocessor definition collision 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. --- 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 1a2e1208e48..f8ba195f521 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