Harumph... I need help. :-\
Given is:
#define SUFFIX X
I need some macro C( n ) that, given that n is a numerical literal (e.g. 42), expands to that same literal with SUFFIX appended:
C( 42 )
-->
42X
I never got familiar with the # and ## operator of the C preprocessor, and I'm lost. Any help appreciated.
C Macro Magic
C Macro Magic
Every good solution is obvious once you've found it.
Re:C Macro Magic
Hm. Found out myself.
You need a level of indirection, because "##" suppresses macro expansion of its arguments. >:(
Sorry for bothering.
Code: Select all
#define SUFFIX X
#define app( x, y ) x ## y
#define append( x, y ) app( x, y )
#define C( value ) append ( value, SUFFIX )
Sorry for bothering.
Every good solution is obvious once you've found it.