Aug 22

宏很有用, 小心别上瘾.

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 平台了
  3. Linux发行版的选择
  4. 如何为Linux生成和打上patch
  5. C 语言常见问题集 (中文)

Written by ideawu at 2009-08-22 13:47:33 | Views: 5237

Leave a Reply

必须登录, 或者浏览器开启JavaScript支持才可以评论!


网站空间,免费试用