Friday, July 24, 2015

Standard headers

Standard headers may be included in any order; each may be included more than once in
a given scope, with no effect different from being included only once, except that the
effect of including <assert.h> depends on the definition of NDEBUG:The assert macro is redefined according to the current state of NDEBUG each time that
<assert.h> is included.

Provided that a library function can be declared without reference to any type defined in a
header, it is also permissible to declare the function and use it without including its
associated header.

There is a sequence point immediately before a library function returns(一般来说,sequence point是分号).

函数签名和宏签名可以相同,以下是例子:
— by use of its associated header (possibly generating a macro expansion)
#include <stdlib.h>
const char *str;
/* ... */
i = atoi(str);
— by use of its associated header (assuredly generating a true function reference)
#include <stdlib.h>
#undef atoi    //明确取消宏定义,只保留函数定义
const char *str;
/* ... */
i = atoi(str);
or
#include <stdlib.h>
const char *str;
/* ... */
i = (atoi)(str);//采用括号来避免宏展开,否则possibly generating a macro expansion
— by explicit declaration
extern int atoi(const char *);
const char *str;
/* ... */
i = atoi(str);
168

No comments:

Post a Comment