google / flatbuffers

FlatBuffers: Memory Efficient Serialization Library
https://flatbuffers.dev/
Apache License 2.0
23.37k stars 3.25k forks source link

Add parentheses in FLATBUFFERS_MAX_BUFFER_SIZE, FLATBUFFERS_MAX_64_BUFFER_SIZE to avoid preprocessor definition collision #8377

Closed mspanc closed 3 months ago

mspanc commented 3 months ago

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.

The previous PR 8375 about the same issue was invalid, I apologise for inconvenience.

mspanc commented 3 months ago

Buildkite seems to be failing due to unrelated errors:

In file included from external/upb/upbc/protoc-gen-upbdefs.cc:32:
In file included from external/upb/upbc/common.h:34:
In file included from external/com_google_absl/absl/strings/substitute.h:81:
In file included from external/com_google_absl/absl/strings/escaping.h:32:
In file included from external/com_google_absl/absl/strings/str_join.h:59:
In file included from external/com_google_absl/absl/strings/internal/str_join_internal.h:42:
In file included from external/com_google_absl/absl/strings/internal/resize_uninitialized.h:26:
external/com_google_absl/absl/meta/type_traits.h:301:36: error: builtin __has_trivial_destructor is deprecated; use __is_trivially_destructible instead [-Werror,-Wdeprecated-builtins]
    : std::integral_constant<bool, __has_trivial_destructor(T)