Use STR and CAT macros for # and ##

This commit is contained in:
Rangi42
2024-03-25 14:16:06 -04:00
parent 2b44672873
commit 8b6ae994b1
2 changed files with 7 additions and 3 deletions

View File

@@ -75,6 +75,10 @@ static inline int clz(unsigned int x) {
#define STR(x) #x
#define EXPAND_AND_STR(x) STR(x)
// Macros for concatenation
#define CAT(x, y) x##y
#define EXPAND_AND_CAT(x, y) CAT(x, y)
// Obtaining the size of an array; `arr` must be an expression, not a type!
// (Having two instances of `arr` is OK because the contents of `sizeof` are not evaluated.)
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof *(arr))