diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-04-11 18:25:43 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-04-11 18:25:43 +0200 |
commit | 28bdc257232da80ae68b52d7f3b8fbfb7f023ca2 (patch) | |
tree | 135a41c3333c6ddd26097c1863523935f9cf03c1 /include | |
parent | c03d68e7b24f7ea1fde1016d6404241e568d415c (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)));
Diffstat (limited to 'include')
-rw-r--r-- | include/macros.h | 6 |
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> |