From cbf5e664fc55cbcc33b10f3058ede325cd133a01 Mon Sep 17 00:00:00 2001 From: dmitrykobets-msft <89153909+dmitrykobets-msft@users.noreply.github.com> Date: Thu, 19 Jan 2023 13:17:39 -0800 Subject: [PATCH] Fix `max` macro collision (#1081) PR https://github.com/microsoft/GSL/pull/1076 introduced a usage of `numeric_limits::max()` function, which seems to have [issues interacting with some Windows headers](https://github.com/skypjack/entt/wiki/Frequently-Asked-Questions#warning-c4003-the-min-the-max-and-the-macro). This PR implements [a simple fix](https://stackoverflow.com/questions/1394132/macro-and-member-function-conflict), which is to wrap the invocations in parentheses. This offloads the fix from the users of the library. --- include/gsl/util | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/gsl/util b/include/gsl/util index 1b0bacf..71f942d 100644 --- a/include/gsl/util +++ b/include/gsl/util @@ -111,7 +111,7 @@ GSL_SUPPRESS(bounds.2) // NO-FORMAT: attribute // clang-format on constexpr T& at(T (&arr)[N], const index i) { - static_assert(N <= static_cast(std::numeric_limits::max()), "We only support arrays up to PTRDIFF_MAX bytes."); + static_assert(N <= static_cast((std::numeric_limits::max)()), "We only support arrays up to PTRDIFF_MAX bytes."); Expects(i >= 0 && i < narrow_cast(N)); return arr[narrow_cast(i)]; }