文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>函数申明__p的用法

函数申明__p的用法

时间:2006-04-04  来源:qwdu

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

void function __P((int));
调用的时候直接使用function()就行了,感觉好奇怪;搜索了一下,在netbsd的maillist有大侠做了解释:
  Use the __P macro from the include file <sys/cdefs.h> 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)

http://mail-index.netbsd.org/tech-misc/2000/01/21/0000.html
相关阅读 更多 +
排行榜 更多 +
昆虫粉碎者

昆虫粉碎者

休闲益智 下载
瀑布战棋

瀑布战棋

休闲益智 下载
变异大对决

变异大对决

休闲益智 下载