From 28bdc257232da80ae68b52d7f3b8fbfb7f023ca2 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Thu, 11 Apr 2024 18:25:43 +0200 Subject: Use __VA_ARGS__ in *eq() macros MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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))); --- include/macros.h | 6 +++--- 1 file 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 -- cgit v1.2.3