Chinaunix首页 | 论坛 | 博客
  • 博客访问: 833187
  • 博文数量: 155
  • 博客积分: 4004
  • 博客等级: 中校
  • 技术积分: 2070
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-19 11:37
文章分类

全部博文(155)

文章存档

2014年(3)

2013年(9)

2012年(28)

2011年(20)

2010年(29)

2009年(66)

我的朋友

分类: C/C++

2011-05-31 00:36:03

宏定义中的井号
1)# 只在有参数的定义时用到,为把参数产开并转化成字符串即用""引起来。里面的空格分割全部改为一个,并且会自动添加转义字符'\'
2)##可以用于有无参数都行。它作用就是把##前后连个东西连起来形成新的标示符。
3)#@和#类似,只不过是用''引起来。
考虑下面的宏
#define stringer( x ) printf( #x "\n" )
stringer( In quotes in the printf function call );
stringer( "In quotes when printed to the screen" );  
stringer( "This: \"  prints an escaped double quote" );
#define F abc
#define B def
#define FB(arg) #arg
#define FB1(arg) FB(arg)
FB(F B)
FB1(F B)
#define paster( n ) printf_s( "token" #n " = %d", token##n )
paster( 9 );
#define makechar(x)  
a = makechar(b);
阅读(1673) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~