macro question
Steven W. Orr
steveo at syslang.net
Thu Oct 8 16:10:41 EDT 2009
On my bag o tricks, I keep these two ditties handy.
#define LIT1(x) #x
#define LIT2(x) LIT1(x)
Then you can play games a la...
#define FOO 44
LIT1(FOO)
LIT2(FOO)
and cpp will print out
"FOO"
"44"
and yes, ## is used for token concatenation.
#define PREF( pre, name) pre ## name
#define P( name ) PREF( SS_, name )
typedef s
{
int P(n1);
int P(n2);
char *P(pp);
} SS;
will yield
typedef s
{
int SS_n1;
int SS_n2;
char *SS_pp;
} SS;
Sometimes it's handy.
--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 261 bytes
Desc: OpenPGP digital signature
Url : http://mail.gnhlug.org/mailman/private/gnhlug-discuss/attachments/20091008/c8674d84/attachment-0001.bin
More information about the gnhlug-discuss
mailing list