aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-04-11 18:25:43 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-04-11 18:25:43 +0200
commit28bdc257232da80ae68b52d7f3b8fbfb7f023ca2 (patch)
tree135a41c3333c6ddd26097c1863523935f9cf03c1
parentc03d68e7b24f7ea1fde1016d6404241e568d415c (diff)
Use __VA_ARGS__ in *eq() macros
This allows for the macros to still work when passed macros as arguments that expand into multiple arguments. As an example, the following which was not possible is now possible: struct u8view sv1 = U8V("Kosiče"); struct u8view sv2 = ...; assert(u8eq(U8_ARGS(sv1), U8_ARGS(sv2)));
-rw-r--r--include/macros.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/macros.h b/include/macros.h
index 5fef367..45eae29 100644
--- a/include/macros.h
+++ b/include/macros.h
@@ -7,9 +7,9 @@
#define lengthof(a) (sizeof(a) / sizeof(*(a)))
-#define memeq(x, y, n) (!memcmp(x, y, n))
-#define streq(x, y) (!strcmp(x, y))
-#define u8eq(x, n, y, m) (!u8cmp(x, n, y, m))
+#define memeq(...) (!memcmp(__VA_ARGS__))
+#define streq(...) (!strcmp(__VA_ARGS__))
+#define u8eq(...) (!u8cmp(__VA_ARGS__))
#ifdef NDEBUG
# include <stddef.h>