Macro Document:
http://developer.apple.com/documentation/DeveloperTools/gcc-4.0.1/cpp/Macros.html#Macros
- 定义宏的返回值
#define macro_name ({statement1;statement2;...;statementn})
则,宏macro_name返回statementn的值;
eg:
#define func(T,x,y) ({T z; z = (x) + (y); z*2;})
printf("20+30=%d\n",func(int,20,30)); //Ouputed value will be 100 - 多行宏
#define macro_name \
do \
{ \
statement1; \
statement2; \
....; \
statementn; \
}while(0) - 关于 '#' 和 '##' 的用法
参见 http://blog.chinaunix.net/u/9577/showart.php?id=221933
- 宏定义中加注释
用 /* */
- ...
阅读(1332) | 评论(0) | 转发(0) |