Robin Chow's C++ Blog

 

[导入]More Exceptional C++ 之 17(待翻译)

使用宏时须注意:
  1. 参数两边要加括号
  2. 整个表达式两边要加括号
  3. 特别注意表达式多次求值的情况,如 max(++i, j)
  4. 宏会搅乱名字空间
  5. 宏不能递归
  6. 宏没有地址
  7. 宏不利于调试
On a compliant compiler, it is not possible for a macro to create any of the following:
  • a trigraph (trigraphs are replaced in phase 1);

  • a universal character name (\uXXXX, replaced in phase 1);

  • an end-of-line line-splicing backslash (replaced in phase 2);

  • a comment (replaced in phase 3);

  • another macro or preprocessing directive (expanded and executed in phase 4); or

  • changes to a character literal (for example, 'x') or string literal (for example, "hello, world") via macro names inside the strings.


文章来源:http://my.donews.com/robinchow/2007/02/11/bavcdirqeacybkdedpxorhuddpwyehtghojl/

posted on 2007-10-23 20:47 Robin Chow 阅读(86) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


导航

统计

常用链接

留言簿(1)

随笔分类

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜