Chr*_*ton 2 c header-files c-preprocessor preprocessor-directive
在Apple的开源网站上,stdarg.h的条目包含以下内容:
#ifndef _STDARG_H
#ifndef _ANSI_STDARG_H_
#ifndef __need___va_list
#define _STDARG_H
#define _ANSI_STDARG_H_
#endif /* not __need___va_list */
#undef __need___va_list
Run Code Online (Sandbox Code Playgroud)
如果第一个参数后面没有任何内容,那么#define语句会做什么?
预处理器中的标识符有三种可能的"值":
第二个,已定义但为空,通常用于条件编译,其中测试仅用于标识符的定义,而不是值:
#ifdef __cplusplus
// here we know we are C++, and we do not care about which version
#endif
#if __cplusplus >= 199711L
// here we know we have a specific version or later
#endif
#ifndef __cplusplus // or #if !defined(__cplusplus)
// here we know we are not C++
#endif
Run Code Online (Sandbox Code Playgroud)
这是一个名称的示例,如果它被定义将具有值.但是还有其他的,比如NDEBUG,它们通常根本没有定义(-DNDEBUG
通常在编译器命令行上).