From 21101d536cca68a523655c16f4ce7aef8d22e79b Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sat, 16 Dec 2023 20:01:20 -0800 Subject: til_util: guard MIN/MAX macros to avoid redefining This is one of those crufty *NIX/C things. I'm tempted to just rename these to TIL_MIN/TIL_MAX, but here just avoid redefining them and accept what's predefined assuming it behaves the same. Tripped over by Sketch building on an M1 MacOS box --- src/til_util.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/til_util.h b/src/til_util.h index 3dc7fc7..8d1be0c 100644 --- a/src/til_util.h +++ b/src/til_util.h @@ -21,11 +21,19 @@ #define cstrlen(_str) \ (sizeof(_str) - 1) +/* Though I don't bother including sys/param.h, some toolchains pull it in indirectly, + * or just define MIN/MAX elsewhere. So I'm just doing the stupid thing here and accepting + * a preexisting MIN/MAX, assuming it's semantically identical. + */ +#ifndef MIN #define MIN(_a, _b) \ ((_a) < (_b) ? (_a) : (_b)) +#endif +#ifndef MAX #define MAX(_a, _b) \ ((_a) > (_b) ? (_a) : (_b)) +#endif unsigned til_get_ncpus(void); -- cgit v1.2.1