#define definer(x) #define #x?
#x is the string x. You cannot #define a string token. (#define "foo".) It must be the identifier [a-zA-Z0-9 _] * .
You cannot nest #define like this. You cannot have #define in #define.
You can have #if inside #if blocks.
#ifdef FOO #ifdef BAR ... #else
You are also somewhat limited to expressions that you can use in #if macros. But sometimes you can get around this. For instance:
#define CONCATENATE_4( a,b,c,d) CONCATENATE_4_AGAIN(a,b,c,d) #define CONCATENATE_4_AGAIN(a,b,c,d) a ## b ## c ## d #define STATIC_ASSERT( EXPRESSION, IDENTIFIER_TEXT) \ typedef char CONCATENATE_4( static_assert____, IDENTIFIER_TEXT, \ ____failed_at_line____, __LINE__ ) \ [ (EXPRESSION) ? 1 : -1 ]
Plus something like:
STATIC_ASSERT( sizeof(int1) == 1, sizeof_int1_equal_1 );
(Yes, I know about #include <stdint.h>. This is just an example.)
source share