Chinaunix首页 | 论坛 | 博客
  • 博客访问: 528022
  • 博文数量: 70
  • 博客积分: 3162
  • 博客等级: 中校
  • 技术积分: 850
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-23 13:30
文章分类
文章存档

2013年(1)

2012年(4)

2011年(1)

2010年(7)

2009年(9)

2008年(20)

2007年(3)

2006年(25)

分类: LINUX

2006-04-04 09:57:59

在看代码的时候,偶然看见有的函数这样申明:

void function __P((int));
调用的时候直接使用function()就行了,感觉好奇怪;搜索了一下,在netbsd的maillist有大侠做了解释:
  Use the __P macro from the include file for prototypes in header files, for compatibility with non-ANSI compilers.  I.e,
     void function __P((int));
还有类似用do{ }while(0);来代替某些宏的申明问题:
/*
 * Macros are capitalized, parenthesized, and should avoid side-effects.
 * If they are an inline expansion of a function, the function is defined
 * all in lowercase, the macro has the same name all in uppercase.  If the
 * macro needs more than a single statement, use do { ... } while (0), so
 * that * a trailing semicolon works.  Right-justify the backslashes; it
 * makes it easier to read.
 */
#define    MACRO(x, y)    do {                        \
    variable = (x) + (y);                        \
    (y) += 2;                            \
} while (0)


阅读(1372) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~