宏替换的几种表达方式
①简单宏替换
#defind Pi 3.14159
或
#ifndef __THIS_FILE__
#define __THIS_FILE__ // 用于防止重复包含文件
…… ……
#endif
___________________________
②条件宏替换
#define p(x) printf(x)
…… ……
p("hello!");
→ hello!
___________________________
③字符宏替换(#@)
#define pchar(x) printf("%c\n", #@x)
…… ……
pchar(a);
→ a
___________________________
④字串宏替换(#)
#define pstring(x) printf("%s\n", #x)
…… ……
pstring(hello!);
→ hello!
___________________________
⑤连接宏替换(##)
#define p( n ) printf( "symbol" #n " = %d", symbol##n )
…… ……
int symbol9 = 9;
p( 9 );
→ symbol9=9