ansi.h的源碼及註釋翻譯

此部分源碼爲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 */


 

發佈了42 篇原創文章 · 獲贊 18 · 訪問量 27萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章