summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-12-16 20:01:20 -0800
committerVito Caputo <vcaputo@pengaru.com>2023-12-16 20:02:43 -0800
commit21101d536cca68a523655c16f4ce7aef8d22e79b (patch)
tree5792ec773d4aef04bf11da9319767051b2d01cbd
parent27a745bc3f9df50455ddc8a8e777aec7d7204aeb (diff)
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
-rw-r--r--src/til_util.h8
1 files changed, 8 insertions, 0 deletions
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);
© All Rights Reserved