ansi.h的源码及注释翻译

来源:互联网 发布:mac整理桌面图标 编辑:程序博客网 时间:2024/06/05 08:02

此部分源码为Minix系统下include目录下的ansi.h文件源码,内容如下:

/*The <ansi.h> header attempts to decide whether the compiler has enough
* conformance to Standard C for Minix to take advantage of.If so,the
* symbol _ANSI is defined(as 31459).Otherwise _ANSI is not defined
* here,but it may be defined by applications that want to bend the rules.
* The magic number in the definition is to inhibit unnecessary bending
* of the rules.(For consistency with the new "#ifdef_ANSI" test in
* the headers._ANSI should really be defined as nothing,but that would
* break many library routines that use "#if _ANSI".)

* if _ANSI ends up being defined,a macro
*
*       _PROTOTYPE(function,params)
*
* is defined.This macro expands in different ways,generating either
* ANSI Standard C prototypes or old-style K&R (Kernighan & Ritchie)
* prototypes,as needed.Finally,some programs use_CONST,_VOIDSTAR etc
* in such a way that they are portable over both ANSI and K&R compilers.
* The appropriate macros are defined here.
*/

/* <ansi.h>头文件尝试着去解决编译器是否有足够
* 与标准C相一致,以便有利于Minix。如果是这样,
* 标志_ANSI是有定义的(象31459)。相反_ANSI在那里不是有定义的,
* 但是它可以通过想要转变的 规则的 请求成为有定义的。
* 魔术数字在定义中是用来抑制不必要的转换
* 的规则。(和新的"ifdef_ANSI"校验一致
* 在头文件。_ANSI被真实的定义为nothing,但是那样可能
* 中断许多使用"#if_ANSI"的库程序)
*
* 如果_ANSI此时变为有定义的,一个宏
*
*       _PROTOTYPE(function,params)
*
* 是有定义的。这个宏在不同的路径发展,根据需要产生
* ANSI标准C标准或old-style K&R (Kernighan & Ritchie)标准两者中的一个。
* 最终,有些程序使用_CONST,_VOIDSTAR etc
* 例如一个方便的超过ANSI和K&R编译程序两者的途径。
* 适当的魔术数字在那里是有定义的。
*/


#ifndef _ANSI_H
#define _ANSI_H

#if __STDC__==1
#define _ANSI_H 31459 /* compiler claims full ANSI conformance */
#endif

#ifdef __GNUC__
#define _ANSI 31459 /* gcc conforms enough even in non-ANSI mode */
#endif

#ifdef _ANSI

/* Keep everything for ANSI prototypes. */
#define _PROTOTYPE(function,params) function params
#define _ARGS(params) params

#define _VOIDSTAR void *
#define _VOID void
#define _CONST const
#define _VOLATILE volatile
#define _SIZET size_t

#else

/* Throw away the parameters for K&R prototypes. */
#define _PROTOTYPE(function,params) function()
#define _ARGS(params) ()

#define _VOIDSTAR void *
#define _VOID void
#define _CONST
#define _VOLATILE
#define _SIZET int

#endif /* _ANSI */

/* This should be defined as restrict when a C99 compiler is used. */
#define _RESTRICT

/* Setting any of _MINIX,_POSIX_C_SOURCE or _POSIX2_SOURCE implies
 * _POSIX_SOURCE. (Seems wrong to put this here in ANSI Space.)
 */
#if defined(_MINIX) || _POSIX_C_SOURCE > 0 || defined(_POSIX2_SOURCE)
#undef _POSIX_SOURCE
#define _POSIX_SOURCE 1
#endif

#endif /* ANSI_H */


 

原创粉丝点击