2009-08-22

C语言类函数宏的参数

Views: 17115 | Add Comments

宏很有用, 小心别上瘾.

1. Stringification, 把参数作为C字符串, "#".

#define M(a) #a

M(hello) => "hello"

2. Concatenation, 字面替换和拼接, "##".

#define M(a) a ## _b

M(hello) => hello_b

## 两边可以放空白字符和注释.

参考: Red Hat Enterprise Linux 3: Using cpp, the C Preprocessor

Related posts:

  1. WordPress开发指南
  2. 在 Windows(Cygwin) 环境下编译 levelDB
  3. 我要转到 Windows 平台了
  4. Linux发行版的选择
  5. C 语言常见问题集 (中文)
Posted by ideawu at 2009-08-22 13:47:33

Leave a Comment