summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/al/lib.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/include/al/lib.h b/include/al/lib.h
index 9aff075..3195e7b 100644
--- a/include/al/lib.h
+++ b/include/al/lib.h
@@ -17,8 +17,14 @@
#define AL_ASSERT_TYPE_SIZE(type, size) \
typedef char type##__size_assert[(!!(sizeof(type) == size)) * 2 - 1]
-#define AL_STATIC_ASSERT(what, a, cmp, b) \
- typedef char what##__assert[(!!(a cmp b)) * 2 - 1]
+#define AL_EXPAND_CMP(a, cmp, b) a cmp b
+#define AL_STATIC_ASSERT(what, ...) \
+ typedef char what##__assert[(!!(AL_EXPAND_CMP(__VA_ARGS__))) * 2 - 1]
+
+#define AL_IS_SIGNED(type) (((type)(-1)) < 0)
+#define AL_TYPES_ARE_EQUAL(t1, t2) \
+ AL_STATIC_ASSERT(t1_size_eq_t2, sizeof(t1), ==, sizeof(t2)); \
+ AL_STATIC_ASSERT(t1_signedness_eq_t2, AL_IS_SIGNED(t1), ==, AL_IS_SIGNED(t2))
#define AL_USE_STDLIB
//#define AL_PARANOID_REALLOC