c preprocessor tricks C #define enum macro macros string concatenation:
"#include
#define NAMES C(RED)C(GREEN)C(BLUE)
#define C(x) x,
enum color { NAMES TOP };
#undef C
#define C(x) #x,
const char * const color_name[] = { NAMES };
int main( void )
{ printf( 'The color is %s.\n', color_name[ RED ]);
printf( 'There are %d colors.\n', TOP ); }"
cl search engine
Prenumerera på:
Kommentarer till inlägget (Atom)
Inga kommentarer:
Skicka en kommentar