📄 stdinc.h
字号:
//==============================================================================
// NAME : STDINC.H
//
// DESC : Standard Include file, Defines all common types and constants
//
// For use with C & C++ Modules
//
// TARGET : - All 16 or 32 bit Intel based targets
// - The MIPS Processor (and all derivatives)
//
// TOOLS : - Borland 3.0 or later compilers and tools (16bit only)
// - Borland 4.x and 5.x
// - Microsoft C/C++ 7.0 or later tools (16 and 32bit)
// - Green Hills (Oasys) C/C++ Compiler 1.8.1 or later (32bits)
// - Watcom C/C++ 10.0 32bit and 16bit compiler
// - Metaware R2.6c for the MIPS (32bit)
// - Metaware R3.3 for intel 16 and 32bit e
//
//==============================================================================
#ifndef STDINC_H
#define STDINC_H
/*- Defines and Macros -------------------------------------------------------*/
#undef NULL /* Correctly Define NULL */
#ifdef __cplusplus
#define NULL (0)
#else
#define NULL ((void*)(0))
#endif
#undef FALSE /* Ignore common defines from previous headers */
#undef TRUE
#undef NO
#undef YES
#undef BAD
#undef GOOD
#undef STOP
#undef GO
#undef CLEAR
#undef SET
#undef OFF
#undef ON
#undef OK
#undef NOTOK
#undef SUCCESS
#undef FAILURE
#undef ERROR
#undef NOERR
#undef EOF
#undef ENABLE
#undef DISABLE
#define FALSE (0) /* See FN#2 */
#define TRUE (1)
#define NO (0)
#define YES (1)
#define BAD (0)
#define GOOD (1)
#define STOP (0)
#define GO (1)
#define CLEAR (0)
#define SET (1)
#define OFF (0)
#define ON (1)
#define OK (0)
#define NOTOK (1)
#define SUCCESS (0)
#define FAILURE (1)
#define VALID (1)
#define INVALID (0)
#define EOF (-1)
#ifndef WIN32
#define NOERROR (0) // Confilicts with WINERROR.H
#endif
#define ENABLE (1)
#define DISABLE (0)
#define MAX( a, b ) ((a)>(b)?(a):(b))
#define MIN( a, b ) ((a)<(b)?(a):(b))
/*- Types --------------------------------------------------------------------*/
/* The following types can be dependant on the memory model the
// and compiler them. */
#if !defined( __TTYPES_H ) /* See FN#3 */
typedef unsigned char uchar; /* Usually 8 Bits */
typedef unsigned short ushort; /* Usually 16 Bits */
typedef unsigned int uint; /* Usually 16 or 32 Bits */
typedef unsigned long ulong; /* Usually 32 bits */
#endif
// These types are always set to be a specific size
// Note: These typedefs will all maintain there proper (indicatd) size for
// boht the 16 and 32 bit models for the 16/32 bit compilers listed
// in the module header.
/* Portable unsigned types
// */
typedef unsigned char Byte; /* Always 8 bits (unsigned) */
typedef unsigned short Word; /* Always 16 bits (unsigned) */
typedef unsigned long Dword; /* Always 32 bits (unsigned) */
/* Portable signed types
// */
typedef char Char; /* Always 8 bits (signed) */
typedef short Short; /* Always 16 bits (signed) */
typedef short Bool; /* Always 16 Bits (signed) */
typedef long Long; /* Always 32 bits (signed) */
/* Other types
// */
typedef short Status; /* Always 16 bits (signed) */
// The status type is used by functions which return 'Success' or 'Failure'
// where 'Success' is always zero and 'Failure' is defined as default value
// of '1' but is also considered to be any non zero value.
//------------------------------------------------------------------------------
// Correctly define size_t for the compiler in use
/* define size_t when using Microsoft Visual C/C++ compiler */
#if defined( _MSC_VER ) && !defined( _SIZE_T_ )
#define _SIZE_T_ unsigned long
typedef unsigned size_t;
#endif
/* Define size_t when using any of the CAD-UL Compilersr */
#if defined( CADUL )
/* the CAD-UL tools do this quite nicely... */
#include <stddef.h>
#endif
/* Define size_t when using the Watcom C/C++ Cimpiler */
#if defined( __WATCOMC__ ) && !defined( _SIZE_T_DEFINED_ )
#define _SIZE_T_DEFINED_
typedef unsigned size_t;
#endif
/* Define size_t when using the Borland 3.x 4.x C/C++ Compiler */
#if defined( __BORLANDC__ ) && !defined( _SIZE_T )
#define _SIZE_T
typedef unsigned size_t;
#endif
/* Define size_t when using the GNU Compiler for the Mips RISC Microprocessor */
#if (defined( __mips__ ) && !defined( _SIZE_T_ )) && !defined( __HIGHC__ )
#define _SIZE_T_ unsigned long
typedef unsigned long size_t;
#endif
/* Define size_t when using the METAWARE */
#if defined( __HIGHC__ ) && !defined( _SIZE_T_DEFINED )
/* The metaware stuff has its own really nifty size_t definition header file. */
#include <sizet.h>
#endif
/* Define size_t when using the Metware for the Mips RISC Microprocessor */
#if defined( _R3000 ) && !defined( _SIZE_T_ ) && !defined( _SIZE_T_DEFINED )
#define _SIZE_T_ unsigned long
typedef unsigned long size_t;
#endif
/*- Constants ----------------------------------------------------------------*/
/* See FN#1 */
#ifdef __cplusplus
#ifndef __TTYPES_H
const Bool False = 0; /* See FN#3 */
const Bool True = 1;
#endif
const Bool No = 0;
const Bool Yes = 1;
const Bool Bad = 0;
const Bool Good = 1;
const Bool Stop = 0;
const Bool Go = 1;
#ifndef SMT /* See FN#1 */
const Bool Clear = 0;
const Bool Set = 1;
#endif
const Bool Off = 0;
const Bool On = 1;
const Status Ok = 0;
const Status Success = 0;
const Status Valid = 0;
const Status Notok = 1;
const Status Failure = 1;
const Status Invalid = 1;
const short Eof = -1;
const short Noerror = 0;
const short Enable = 1;
const short Disable = 0;
#else
#define False ((Bool)(0)) /* See FN#3 */
#define True ((Bool)(1))
#define No ((Bool)(0))
#define Yes ((Bool)(1))
#define Bad ((Bool)(0))
#define Good ((Bool)(1))
#define Stop ((Bool)(0))
#define Go ((Bool)(1))
#ifndef SMT /* See FN#1 */
#define Clear ((Bool)(0))
#define Set ((Bool)(1))
#endif
#define Off ((Bool)(0))
#define On ((Bool)(1))
#define Ok ((Status)(0))
#define Success ((Status)(0))
#define Valid ((Status)(0))
#define Notok ((Status)(1))
#define Failure ((Status)(1))
#define Invalid ((Status)(1))
#define Eof ((Status)(-1))
#define Noerror ((Status)( 0))
#define Enable ((Status)(1))
#define Disable ((Status)(0))
#endif
//------------------------------------------------------------------------------
#endif // STDINC_H
/*=============================================================================
Foot Notes
FN#1 -------------------------------------------------------------------------
Note that global types are not declared using Enumerations. This is because
the size of an enumeration is compiler dependant. While this can often be
controlled (usually between an int or char) using compiler switches, it is
highly non-portable so we don't do it here.
FN#2 -------------------------------------------------------------------------
All tokens that are in UPPER CASE should are assumed to be #defined.
Constants and typedefes, structs, and class names, all begin with a capital
letter.
FN#3 -------------------------------------------------------------------------
The TurboVision header file TTYPES.H defines True and False as an enum
of Boolean type. We must not conflict with TurboVision. Note that
since TurboVision is a C++ system, we do not have to do this when
this header is included in a C module.
FN#4 -------------------------------------------------------------------------
The SMT (FDDI Station Managment Task) software from DSI inc. Defines these
itself. So we will be will behaved instead of changing their released
code.
*/
/*==============================================================================
// FOOT NOTES :
FN#1 -------------------------------------------------------------------------
Note that global types are not declared using Enumerations. This is because
the size of an enumeration is compiler dependant. While this can often be
controlled (usually between an int or char) using compiler switches, it is
highly non-portable so we don't do it here.
FN#2 -------------------------------------------------------------------------
All tokens that are in UPPER CASE should are assumed to be #defined.
Constants and typedefes, structs, and class names, all begin with a capital
letter.
FN#3 -------------------------------------------------------------------------
The TurboVision header file TTYPES.H defines True and False as an enum
of Boolean type. We must not conflict with TurboVision. Note that
since TurboVision is a C++ system, we do not have to do this when
this header is included in a C module.
FN#4 -------------------------------------------------------------------------
The SMT (FDDI Station Managment Task) software from DSI inc. Defines these
itself. So we will be will behaved instead of changing their released
code.
//------------------------------------------------------------------------------
// HISTORY:
//
// $Log: stdinc.h $
// Revision 1.1 1998/03/26 14:19:36 rrussell
// Initial revision
//
// -----------------------------------------------------------------------------
// ENDOF : STDINC.C
// ===========================================================================*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -