mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Use STR and CAT macros for # and ##
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -1270,9 +1270,9 @@ int main(int argc, char *argv[]) {
|
||||
#define SPEC_G TRASH_GLOBAL_SUM
|
||||
#define overrideSpec(cur, bad) \
|
||||
do { \
|
||||
if (fixSpec & SPEC_##bad) \
|
||||
fprintf(stderr, "warning: '" #cur "' overriding '" #bad "' in fix spec\n"); \
|
||||
fixSpec = (fixSpec & ~SPEC_##bad) | SPEC_##cur; \
|
||||
if (fixSpec & CAT(SPEC_, bad)) \
|
||||
fprintf(stderr, "warning: '" STR(cur) "' overriding '" STR(bad) "' in fix spec\n"); \
|
||||
fixSpec = (fixSpec & ~CAT(SPEC_, bad)) | CAT(SPEC_, cur); \
|
||||
} while (0)
|
||||
case 'l':
|
||||
overrideSpec(l, L);
|
||||
|
||||
Reference in New Issue
Block a user