VC98\include\stdlib.h文件全部内容
我们先来看看古老的TC2中stdlib.h文件的内容,如下:

 TC2下的stdlib.h
TC2下的stdlib.h1

 /**//*      stdlib.h
/**//*      stdlib.h2

3
 Definitions for common types, variables, and functions.
        Definitions for common types, variables, and functions.4

5
 Copyright (c) Borland International 1987,1988
        Copyright (c) Borland International 1987,19886
 All Rights Reserved.
        All Rights Reserved.7
 */
*/8
 #if __STDC__
#if __STDC__9
 #define _Cdecl
#define _Cdecl10
 #else
#else11
 #define _Cdecl  cdecl
#define _Cdecl  cdecl12
 #endif
#endif13

14
 #if     !defined(__STDLIB)
#if     !defined(__STDLIB)15
 #define __STDLIB
#define __STDLIB16

17
 #ifndef _SIZE_T
#ifndef _SIZE_T18
 #define _SIZE_T
#define _SIZE_T19
 typedef unsigned size_t;
typedef unsigned size_t;20
 #endif
#endif21

22
 #ifndef _DIV_T
#ifndef _DIV_T23
 #define _DIV_T
#define _DIV_T24

 typedef struct
typedef struct  {
{25
 int     quot;
        int     quot;26
 int     rem;
        int     rem;27
 } div_t;
} div_t;28
 #endif
#endif29

30
 #ifndef _LDIV_T
#ifndef _LDIV_T31
 #define _LDIV_T
#define _LDIV_T32

 typedef struct
typedef struct  {
{33
 long    quot;
        long    quot;34
 long    rem;
        long    rem;35
 } ldiv_t;
} ldiv_t;36
 #endif
#endif37

38
 #define EXIT_SUCCESS 0
#define EXIT_SUCCESS 039
 #define EXIT_FAILURE 1
#define EXIT_FAILURE 140

41

 /**//* Maximum value returned by "rand" function
/**//* Maximum value returned by "rand" function42
 */
*/43
 #define RAND_MAX 0x7FFF
#define RAND_MAX 0x7FFF44

45
 typedef void _Cdecl (* atexit_t)(void);
typedef void _Cdecl (* atexit_t)(void);46

47
 void    _Cdecl abort  (void);
void    _Cdecl abort  (void);48
 int     _Cdecl abs    (int x);
int     _Cdecl abs    (int x);49
 int     _Cdecl atexit (atexit_t func);
int     _Cdecl atexit (atexit_t func);50
 double  _Cdecl atof   (const char *s);
double  _Cdecl atof   (const char *s);51
 int     _Cdecl atoi   (const char *s);
int     _Cdecl atoi   (const char *s);52
 long    _Cdecl atol   (const char *s);
long    _Cdecl atol   (const char *s);53
 void   *_Cdecl bsearch(const void *key, const void *base,
void   *_Cdecl bsearch(const void *key, const void *base, 54
 size_t nelem, size_t width,
                       size_t nelem, size_t width,55

 int _Cdecl (*fcmp)(/**//* const void *, const void * */));
                       int _Cdecl (*fcmp)(/**//* const void *, const void * */));56
 void   *_Cdecl calloc (size_t nitems, size_t size);
void   *_Cdecl calloc (size_t nitems, size_t size);57
 div_t   _Cdecl div    (int numer, int denom);
div_t   _Cdecl div    (int numer, int denom);58
 void    _Cdecl exit   (int status);
void    _Cdecl exit   (int status);59
 void    _Cdecl free   (void *block);
void    _Cdecl free   (void *block);60
 char   *_Cdecl getenv (const char *name);
char   *_Cdecl getenv (const char *name);61
 long    _Cdecl labs   (long x);
long    _Cdecl labs   (long x);62
 ldiv_t  _Cdecl ldiv   (long numer, long denom);
ldiv_t  _Cdecl ldiv   (long numer, long denom);63
 void   *_Cdecl malloc (size_t size);
void   *_Cdecl malloc (size_t size);64
 void    _Cdecl qsort  (void *base, size_t nelem, size_t width,
void    _Cdecl qsort  (void *base, size_t nelem, size_t width,65

 int _Cdecl (*fcmp)(/**//* const void *, const void * */));
                       int _Cdecl (*fcmp)(/**//* const void *, const void * */));66
 int     _Cdecl rand   (void);
int     _Cdecl rand   (void);67
 void   *_Cdecl realloc(void *block, size_t size);
void   *_Cdecl realloc(void *block, size_t size);68
 void    _Cdecl srand  (unsigned seed);
void    _Cdecl srand  (unsigned seed);69
 double  _Cdecl strtod (const char *s, char **endptr);
double  _Cdecl strtod (const char *s, char **endptr);70
 long    _Cdecl strtol (const char *s, char **endptr, int radix);
long    _Cdecl strtol (const char *s, char **endptr, int radix);71
 unsigned long _Cdecl strtoul (const char *s, char **endptr, int radix);
unsigned long _Cdecl strtoul (const char *s, char **endptr, int radix);72
 int     _Cdecl system (const char *command);
int     _Cdecl system (const char *command);73

74
 #if !__STDC__
#if !__STDC__75

76
 #ifndef NULL
#ifndef NULL77
 #if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
#if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)78
 #define NULL    0
#define NULL    079
 #else
#else80
 #define NULL    0L
#define NULL    0L81
 #endif
#endif82
 #endif
#endif83

84

 /**//* Variables */
/**//* Variables */85
 extern  int             _Cdecl _doserrno;
extern  int             _Cdecl _doserrno;86
 extern  char          **_Cdecl environ;
extern  char          **_Cdecl environ;87
 extern  int             _Cdecl errno;
extern  int             _Cdecl errno;88
 extern  int             _Cdecl _fmode;
extern  int             _Cdecl _fmode;89
 extern  unsigned char   _Cdecl _osmajor;
extern  unsigned char   _Cdecl _osmajor;90
 extern  unsigned char   _Cdecl _osminor;
extern  unsigned char   _Cdecl _osminor;91
 extern  unsigned        _Cdecl _psp;
extern  unsigned        _Cdecl _psp;92
 extern  char           *_Cdecl sys_errlist[];
extern  char           *_Cdecl sys_errlist[];93
 extern  int             _Cdecl sys_nerr;
extern  int             _Cdecl sys_nerr;94
 extern  unsigned int    _Cdecl _version;
extern  unsigned int    _Cdecl _version;95

96

 int     _Cdecl __abs__(int x);          /**//* This is an in-line function */
int     _Cdecl __abs__(int x);          /**//* This is an in-line function */97
 #define abs(x)          __abs__(x)
#define abs(x)          __abs__(x)98
 #define atoi(s)         ((int) atol (s))
#define atoi(s)         ((int) atol (s))99

100
 #define max(a,b)        (((a) > (b)) ? (a) : (b))
#define max(a,b)        (((a) > (b)) ? (a) : (b))101
 #define min(a,b)        (((a) < (b)) ? (a) : (b))
#define min(a,b)        (((a) < (b)) ? (a) : (b))102

103
 #define random(num)     (rand() % (num))
#define random(num)     (rand() % (num))104
 #define randomize()     srand((unsigned)time(NULL))
#define randomize()     srand((unsigned)time(NULL))105

106
 char   *_Cdecl ecvt     (double value, int ndig, int *dec, int *sign);
char   *_Cdecl ecvt     (double value, int ndig, int *dec, int *sign);107
 void    _Cdecl _exit    (int status);
void    _Cdecl _exit    (int status);108
 char   *_Cdecl fcvt     (double value, int ndig, int *dec, int *sign);
char   *_Cdecl fcvt     (double value, int ndig, int *dec, int *sign);109
 char   *_Cdecl gcvt     (double value, int ndec, char *buf);
char   *_Cdecl gcvt     (double value, int ndec, char *buf);110
 char   *_Cdecl itoa     (int value, char *string, int radix);
char   *_Cdecl itoa     (int value, char *string, int radix);111
 void   *_Cdecl lfind    (const void *key, const void *base,
void   *_Cdecl lfind    (const void *key, const void *base, 112
 size_t *num, size_t width,
                         size_t *num, size_t width,113

 int _Cdecl (*fcmp)(/**//* const void *, const void * */));
                         int _Cdecl (*fcmp)(/**//* const void *, const void * */));114

115
 unsigned long _Cdecl _lrotl(unsigned long val, int count);
unsigned long _Cdecl _lrotl(unsigned long val, int count);116
 unsigned long _Cdecl _lrotr(unsigned long val, int count);
unsigned long _Cdecl _lrotr(unsigned long val, int count);117

118
 void   *_Cdecl lsearch  (const void *key, void *base,
void   *_Cdecl lsearch  (const void *key, void *base, 119
 size_t *num, size_t width,
                         size_t *num, size_t width, 120

 int _Cdecl (*fcmp)(/**//* const void *, const void * */));
                         int _Cdecl (*fcmp)(/**//* const void *, const void * */));121
 char   *_Cdecl ltoa     (long value, char *string, int radix);
char   *_Cdecl ltoa     (long value, char *string, int radix);122
 int     _Cdecl putenv   (const char *name);
int     _Cdecl putenv   (const char *name);123

124
 unsigned _Cdecl _rotl   (unsigned value, int count);
unsigned _Cdecl _rotl   (unsigned value, int count);125
 unsigned _Cdecl _rotr   (unsigned value, int count);
unsigned _Cdecl _rotr   (unsigned value, int count);126

127
 void    _Cdecl swab     (char *from, char *to, int nbytes);
void    _Cdecl swab     (char *from, char *to, int nbytes);128
 char   *_Cdecl ultoa    (unsigned long value, char *string, int radix);
char   *_Cdecl ultoa    (unsigned long value, char *string, int radix);129
 #endif
#endif130

131
 #endif
#endif132

我们再来看看MS的VC编译器中的stdlib.h文件的内容,如下:

 MS的VC编译器中附带的stdlib.h
MS的VC编译器中附带的stdlib.h1

 /**//***
/**//***2
 *stdlib.h - declarations/definitions for commonly used library functions
*stdlib.h - declarations/definitions for commonly used library functions3
 *
*4
 *       Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
*       Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.5
 *
*6
 *Purpose:
*Purpose:7
 *       This include file contains the function declarations for commonly
*       This include file contains the function declarations for commonly8
 *       used library functions which either don't fit somewhere else, or,
*       used library functions which either don't fit somewhere else, or,9
 *       cannot be declared in the normal place for other reasons.
*       cannot be declared in the normal place for other reasons.10
 *       [ANSI]
*       [ANSI]11
 *
*12
 *       [Public]
*       [Public]13
 *
*14
 ****/
****/15

16
 #if     _MSC_VER > 1000
#if     _MSC_VER > 100017
 #pragma once
#pragma once18
 #endif
#endif19

20
 #ifndef _INC_STDLIB
#ifndef _INC_STDLIB21
 #define _INC_STDLIB
#define _INC_STDLIB22

23
 #if     !defined(_WIN32) && !defined(_MAC)
#if     !defined(_WIN32) && !defined(_MAC)24
 #error ERROR: Only Mac or Win32 targets supported!
#error ERROR: Only Mac or Win32 targets supported!25
 #endif
#endif26

27

28
 #ifdef  _MSC_VER
#ifdef  _MSC_VER29

 /**//*
/**//*30
 * Currently, all MS C compilers for Win32 platforms default to 8 byte
 * Currently, all MS C compilers for Win32 platforms default to 8 byte31
 * alignment.
 * alignment.32
 */
 */33
 #pragma pack(push,8)
#pragma pack(push,8)34
 #endif  /* _MSC_VER */
#endif  /* _MSC_VER */35

36
 #ifdef  __cplusplus
#ifdef  __cplusplus37

 extern "C"
extern "C"  {
{38
 #endif
#endif39

40

41

42

 /**//* Define _CRTIMP */
/**//* Define _CRTIMP */43

44
 #ifndef _CRTIMP
#ifndef _CRTIMP45
 #ifdef  _DLL
#ifdef  _DLL46
 #define _CRTIMP __declspec(dllimport)
#define _CRTIMP __declspec(dllimport)47
 #else   /* ndef _DLL */
#else   /* ndef _DLL */48
 #define _CRTIMP
#define _CRTIMP49
 #endif  /* _DLL */
#endif  /* _DLL */50
 #endif  /* _CRTIMP */
#endif  /* _CRTIMP */51

52

53

 /**//* Define __cdecl for non-Microsoft compilers */
/**//* Define __cdecl for non-Microsoft compilers */54

55
 #if     ( !defined(_MSC_VER) && !defined(__cdecl) )
#if     ( !defined(_MSC_VER) && !defined(__cdecl) )56
 #define __cdecl
#define __cdecl57
 #endif
#endif58

59

 /**//* Define _CRTAPI1 (for compatibility with the NT SDK) */
/**//* Define _CRTAPI1 (for compatibility with the NT SDK) */60

61
 #ifndef _CRTAPI1
#ifndef _CRTAPI162
 #if    _MSC_VER >= 800 && _M_IX86 >= 300
#if    _MSC_VER >= 800 && _M_IX86 >= 30063
 #define _CRTAPI1 __cdecl
#define _CRTAPI1 __cdecl64
 #else
#else65
 #define _CRTAPI1
#define _CRTAPI166
 #endif
#endif67
 #endif
#endif68

69

70
 #ifndef _SIZE_T_DEFINED
#ifndef _SIZE_T_DEFINED71
 typedef unsigned int size_t;
typedef unsigned int size_t;72
 #define _SIZE_T_DEFINED
#define _SIZE_T_DEFINED73
 #endif
#endif74

75

76
 #ifndef _WCHAR_T_DEFINED
#ifndef _WCHAR_T_DEFINED77
 typedef unsigned short wchar_t;
typedef unsigned short wchar_t;78
 #define _WCHAR_T_DEFINED
#define _WCHAR_T_DEFINED79
 #endif
#endif80

81

82

 /**//* Define NULL pointer value */
/**//* Define NULL pointer value */83

84
 #ifndef NULL
#ifndef NULL85
 #ifdef __cplusplus
#ifdef __cplusplus86
 #define NULL    0
#define NULL    087
 #else
#else88
 #define NULL    ((void *)0)
#define NULL    ((void *)0)89
 #endif
#endif90
 #endif
#endif91

92

93

 /**//* Definition of the argument values for the exit() function */
/**//* Definition of the argument values for the exit() function */94

95
 #define EXIT_SUCCESS    0
#define EXIT_SUCCESS    096
 #define EXIT_FAILURE    1
#define EXIT_FAILURE    197

98

99
 #ifndef _ONEXIT_T_DEFINED
#ifndef _ONEXIT_T_DEFINED100
 typedef int (__cdecl * _onexit_t)(void);
typedef int (__cdecl * _onexit_t)(void);101
 #if     !__STDC__
#if     !__STDC__102

 /**//* Non-ANSI name for compatibility */
/**//* Non-ANSI name for compatibility */103
 #define onexit_t _onexit_t
#define onexit_t _onexit_t104
 #endif
#endif105
 #define _ONEXIT_T_DEFINED
#define _ONEXIT_T_DEFINED106
 #endif
#endif107

108

109

 /**//* Data structure definitions for div and ldiv runtimes. */
/**//* Data structure definitions for div and ldiv runtimes. */110

111
 #ifndef _DIV_T_DEFINED
#ifndef _DIV_T_DEFINED112

113

 typedef struct _div_t
typedef struct _div_t  {
{114
 int quot;
        int quot;115
 int rem;
        int rem;116
 } div_t;
} div_t;117

118

 typedef struct _ldiv_t
typedef struct _ldiv_t  {
{119
 long quot;
        long quot;120
 long rem;
        long rem;121
 } ldiv_t;
} ldiv_t;122

123
 #define _DIV_T_DEFINED
#define _DIV_T_DEFINED124
 #endif
#endif125

126

127

 /**//* Maximum value that can be returned by the rand function. */
/**//* Maximum value that can be returned by the rand function. */128

129
 #define RAND_MAX 0x7fff
#define RAND_MAX 0x7fff130

131

 /**//*
/**//*132
 * Maximum number of bytes in multi-byte character in the current locale
 * Maximum number of bytes in multi-byte character in the current locale133
 * (also defined in ctype.h).
 * (also defined in ctype.h).134
 */
 */135
 #ifndef MB_CUR_MAX
#ifndef MB_CUR_MAX136
 #define MB_CUR_MAX __mb_cur_max
#define MB_CUR_MAX __mb_cur_max137
 _CRTIMP extern int __mb_cur_max;
_CRTIMP extern int __mb_cur_max;138
 #endif  /* MB_CUR_MAX */
#endif  /* MB_CUR_MAX */139

140

141

 /**//* Minimum and maximum macros */
/**//* Minimum and maximum macros */142

143
 #define __max(a,b)  (((a) > (b)) ? (a) : (b))
#define __max(a,b)  (((a) > (b)) ? (a) : (b))144
 #define __min(a,b)  (((a) < (b)) ? (a) : (b))
#define __min(a,b)  (((a) < (b)) ? (a) : (b))145

146

 /**//*
/**//*147
 * Sizes for buffers used by the _makepath() and _splitpath() functions.
 * Sizes for buffers used by the _makepath() and _splitpath() functions.148
 * note that the sizes include space for 0-terminator
 * note that the sizes include space for 0-terminator149
 */
 */150
 #ifndef _MAC
#ifndef _MAC151
 #define _MAX_PATH   260 /* max. length of full pathname */
#define _MAX_PATH   260 /* max. length of full pathname */152
 #define _MAX_DRIVE  3   /* max. length of drive component */
#define _MAX_DRIVE  3   /* max. length of drive component */153
 #define _MAX_DIR    256 /* max. length of path component */
#define _MAX_DIR    256 /* max. length of path component */154
 #define _MAX_FNAME  256 /* max. length of file name component */
#define _MAX_FNAME  256 /* max. length of file name component */155
 #define _MAX_EXT    256 /* max. length of extension component */
#define _MAX_EXT    256 /* max. length of extension component */156
 #else   /* def _MAC */
#else   /* def _MAC */157
 #define _MAX_PATH   256 /* max. length of full pathname */
#define _MAX_PATH   256 /* max. length of full pathname */158
 #define _MAX_DIR    32  /* max. length of path component */
#define _MAX_DIR    32  /* max. length of path component */159
 #define _MAX_FNAME  64  /* max. length of file name component */
#define _MAX_FNAME  64  /* max. length of file name component */160
 #endif  /* _MAC */
#endif  /* _MAC */161

162

 /**//*
/**//*163
 * Argument values for _set_error_mode().
 * Argument values for _set_error_mode().164
 */
 */165
 #define _OUT_TO_DEFAULT 0
#define _OUT_TO_DEFAULT 0166
 #define _OUT_TO_STDERR  1
#define _OUT_TO_STDERR  1167
 #define _OUT_TO_MSGBOX  2
#define _OUT_TO_MSGBOX  2168
 #define _REPORT_ERRMODE 3
#define _REPORT_ERRMODE 3169

170

171

 /**//* External variable declarations */
/**//* External variable declarations */172

173
 #if     (defined(_MT) || defined(_DLL)) && !defined(_MAC)
#if     (defined(_MT) || defined(_DLL)) && !defined(_MAC)174
 _CRTIMP int * __cdecl _errno(void);
_CRTIMP int * __cdecl _errno(void);175
 _CRTIMP unsigned long * __cdecl __doserrno(void);
_CRTIMP unsigned long * __cdecl __doserrno(void);176
 #define errno       (*_errno())
#define errno       (*_errno())177
 #define _doserrno   (*__doserrno())
#define _doserrno   (*__doserrno())178
 #else   /* ndef _MT && ndef _DLL */
#else   /* ndef _MT && ndef _DLL */179

 _CRTIMP extern int errno;               /**//* XENIX style error number */
_CRTIMP extern int errno;               /**//* XENIX style error number */180

 _CRTIMP extern unsigned long _doserrno; /**//* OS system error value */
_CRTIMP extern unsigned long _doserrno; /**//* OS system error value */181
 #endif  /* _MT || _DLL */
#endif  /* _MT || _DLL */182

183

184
 #ifdef  _MAC
#ifdef  _MAC185

 _CRTIMP extern int  _macerrno;          /**//* OS system error value */
_CRTIMP extern int  _macerrno;          /**//* OS system error value */186
 #endif
#endif187

188

189

 _CRTIMP extern char * _sys_errlist[];   /**//* perror error message table */
_CRTIMP extern char * _sys_errlist[];   /**//* perror error message table */190

 _CRTIMP extern int _sys_nerr;           /**//* # of entries in sys_errlist table */
_CRTIMP extern int _sys_nerr;           /**//* # of entries in sys_errlist table */191

192

193
 #if     defined(_DLL) && defined(_M_IX86)
#if     defined(_DLL) && defined(_M_IX86)194

195
 #define __argc      (*__p___argc())     /* count of cmd line args */
#define __argc      (*__p___argc())     /* count of cmd line args */196
 #define __argv      (*__p___argv())     /* pointer to table of cmd line args */
#define __argv      (*__p___argv())     /* pointer to table of cmd line args */197
 #define __wargv     (*__p___wargv())    /* pointer to table of wide cmd line args */
#define __wargv     (*__p___wargv())    /* pointer to table of wide cmd line args */198
 #define _environ    (*__p__environ())   /* pointer to environment table */
#define _environ    (*__p__environ())   /* pointer to environment table */199
 #ifdef _POSIX_
#ifdef _POSIX_200

 extern char ** environ;                 /**//* pointer to environment table */
extern char ** environ;                 /**//* pointer to environment table */201
 #else
#else202
 #ifndef _MAC
#ifndef _MAC203
 #define _wenviron   (*__p__wenviron())  /* pointer to wide environment table */
#define _wenviron   (*__p__wenviron())  /* pointer to wide environment table */204
 #endif  /* ndef _MAC */
#endif  /* ndef _MAC */205
 #endif /* _POSIX_ */
#endif /* _POSIX_ */206
 #define _pgmptr     (*__p__pgmptr())    /* points to the module (EXE) name */
#define _pgmptr     (*__p__pgmptr())    /* points to the module (EXE) name */207
 #ifndef _MAC
#ifndef _MAC208
 #define _wpgmptr    (*__p__wpgmptr())   /* points to the module (EXE) wide name */
#define _wpgmptr    (*__p__wpgmptr())   /* points to the module (EXE) wide name */209
 #endif  /* ndef _MAC */
#endif  /* ndef _MAC */210

211
 _CRTIMP int *          __cdecl __p___argc(void);
_CRTIMP int *          __cdecl __p___argc(void);212
 _CRTIMP char ***       __cdecl __p___argv(void);
_CRTIMP char ***       __cdecl __p___argv(void);213
 _CRTIMP wchar_t ***    __cdecl __p___wargv(void);
_CRTIMP wchar_t ***    __cdecl __p___wargv(void);214
 _CRTIMP char ***       __cdecl __p__environ(void);
_CRTIMP char ***       __cdecl __p__environ(void);215
 _CRTIMP wchar_t ***    __cdecl __p__wenviron(void);
_CRTIMP wchar_t ***    __cdecl __p__wenviron(void);216
 _CRTIMP char **        __cdecl __p__pgmptr(void);
_CRTIMP char **        __cdecl __p__pgmptr(void);217
 _CRTIMP wchar_t **     __cdecl __p__wpgmptr(void);
_CRTIMP wchar_t **     __cdecl __p__wpgmptr(void);218

219

220
 #else
#else221

222

 _CRTIMP extern int __argc;          /**//* count of cmd line args */
_CRTIMP extern int __argc;          /**//* count of cmd line args */223

 _CRTIMP extern char ** __argv;      /**//* pointer to table of cmd line args */
_CRTIMP extern char ** __argv;      /**//* pointer to table of cmd line args */224
 #ifndef _MAC
#ifndef _MAC225

 _CRTIMP extern wchar_t ** __wargv;  /**//* pointer to table of wide cmd line args */
_CRTIMP extern wchar_t ** __wargv;  /**//* pointer to table of wide cmd line args */226
 #endif  /* ndef _MAC */
#endif  /* ndef _MAC */227

228
 #ifdef _POSIX_
#ifdef _POSIX_229

 extern char ** environ;             /**//* pointer to environment table */
extern char ** environ;             /**//* pointer to environment table */230
 #else
#else231

 _CRTIMP extern char ** _environ;    /**//* pointer to environment table */
_CRTIMP extern char ** _environ;    /**//* pointer to environment table */232
 #ifndef _MAC
#ifndef _MAC233

 _CRTIMP extern wchar_t ** _wenviron;    /**//* pointer to wide environment table */
_CRTIMP extern wchar_t ** _wenviron;    /**//* pointer to wide environment table */234
 #endif  /* ndef _MAC */
#endif  /* ndef _MAC */235
 #endif  /* _POSIX_ */
#endif  /* _POSIX_ */236

237

 _CRTIMP extern char * _pgmptr;      /**//* points to the module (EXE) name */
_CRTIMP extern char * _pgmptr;      /**//* points to the module (EXE) name */238
 #ifndef _MAC
#ifndef _MAC239

 _CRTIMP extern wchar_t * _wpgmptr;  /**//* points to the module (EXE) wide name */
_CRTIMP extern wchar_t * _wpgmptr;  /**//* points to the module (EXE) wide name */240
 #endif  /* ndef _MAC */
#endif  /* ndef _MAC */241

242
 #endif
#endif243

244

245

 _CRTIMP extern int _fmode;          /**//* default file translation mode */
_CRTIMP extern int _fmode;          /**//* default file translation mode */246

 _CRTIMP extern int _fileinfo;       /**//* open file info mode (for spawn) */
_CRTIMP extern int _fileinfo;       /**//* open file info mode (for spawn) */247

248

249

 /**//* Windows major/minor and O.S. version numbers */
/**//* Windows major/minor and O.S. version numbers */250

251
 _CRTIMP extern unsigned int _osver;
_CRTIMP extern unsigned int _osver;252
 _CRTIMP extern unsigned int _winver;
_CRTIMP extern unsigned int _winver;253
 _CRTIMP extern unsigned int _winmajor;
_CRTIMP extern unsigned int _winmajor;254
 _CRTIMP extern unsigned int _winminor;
_CRTIMP extern unsigned int _winminor;255

256

257

 /**//* function prototypes */
/**//* function prototypes */258

259
 #if     _MSC_VER >= 1200
#if     _MSC_VER >= 1200260
 _CRTIMP __declspec(noreturn) void   __cdecl abort(void);
_CRTIMP __declspec(noreturn) void   __cdecl abort(void);261
 _CRTIMP __declspec(noreturn) void   __cdecl exit(int);
_CRTIMP __declspec(noreturn) void   __cdecl exit(int);262
 #else
#else263
 _CRTIMP void   __cdecl abort(void);
_CRTIMP void   __cdecl abort(void);264
 _CRTIMP void   __cdecl exit(int);
_CRTIMP void   __cdecl exit(int);265
 #endif
#endif266

267
 #if defined(_M_MRX000)
#if defined(_M_MRX000)268
 _CRTIMP int    __cdecl abs(int);
_CRTIMP int    __cdecl abs(int);269
 #else
#else270
 int    __cdecl abs(int);
        int    __cdecl abs(int);271
 #endif
#endif272
 int    __cdecl atexit(void (__cdecl *)(void));
        int    __cdecl atexit(void (__cdecl *)(void));273
 _CRTIMP double __cdecl atof(const char *);
_CRTIMP double __cdecl atof(const char *);274
 _CRTIMP int    __cdecl atoi(const char *);
_CRTIMP int    __cdecl atoi(const char *);275
 _CRTIMP long   __cdecl atol(const char *);
_CRTIMP long   __cdecl atol(const char *);276
 #ifdef  _M_M68K
#ifdef  _M_M68K277
 _CRTIMP long double __cdecl _atold(const char *);
_CRTIMP long double __cdecl _atold(const char *);278
 #endif
#endif279
 _CRTIMP void * __cdecl bsearch(const void *, const void *, size_t, size_t,
_CRTIMP void * __cdecl bsearch(const void *, const void *, size_t, size_t,280
 int (__cdecl *)(const void *, const void *));
        int (__cdecl *)(const void *, const void *));281
 _CRTIMP void * __cdecl calloc(size_t, size_t);
_CRTIMP void * __cdecl calloc(size_t, size_t);282
 _CRTIMP div_t  __cdecl div(int, int);
_CRTIMP div_t  __cdecl div(int, int);283
 _CRTIMP void   __cdecl free(void *);
_CRTIMP void   __cdecl free(void *);284
 _CRTIMP char * __cdecl getenv(const char *);
_CRTIMP char * __cdecl getenv(const char *);285
 _CRTIMP char * __cdecl _itoa(int, char *, int);
_CRTIMP char * __cdecl _itoa(int, char *, int);286
 #if     _INTEGRAL_MAX_BITS >= 64
#if     _INTEGRAL_MAX_BITS >= 64287
 _CRTIMP char * __cdecl _i64toa(__int64, char *, int);
_CRTIMP char * __cdecl _i64toa(__int64, char *, int);288
 _CRTIMP char * __cdecl _ui64toa(unsigned __int64, char *, int);
_CRTIMP char * __cdecl _ui64toa(unsigned __int64, char *, int);289
 _CRTIMP __int64 __cdecl _atoi64(const char *);
_CRTIMP __int64 __cdecl _atoi64(const char *);290
 #endif
#endif291
 #if     defined(_M_MRX000)
#if     defined(_M_MRX000)292
 _CRTIMP long __cdecl labs(long);
_CRTIMP long __cdecl labs(long);293
 #else
#else294
 long __cdecl labs(long);
        long __cdecl labs(long);295
 #endif
#endif296
 _CRTIMP ldiv_t __cdecl ldiv(long, long);
_CRTIMP ldiv_t __cdecl ldiv(long, long);297
 _CRTIMP char * __cdecl _ltoa(long, char *, int);
_CRTIMP char * __cdecl _ltoa(long, char *, int);298
 _CRTIMP void * __cdecl malloc(size_t);
_CRTIMP void * __cdecl malloc(size_t);299
 _CRTIMP int    __cdecl mblen(const char *, size_t);
_CRTIMP int    __cdecl mblen(const char *, size_t);300
 _CRTIMP size_t __cdecl _mbstrlen(const char *s);
_CRTIMP size_t __cdecl _mbstrlen(const char *s);301
 _CRTIMP int    __cdecl mbtowc(wchar_t *, const char *, size_t);
_CRTIMP int    __cdecl mbtowc(wchar_t *, const char *, size_t);302
 _CRTIMP size_t __cdecl mbstowcs(wchar_t *, const char *, size_t);
_CRTIMP size_t __cdecl mbstowcs(wchar_t *, const char *, size_t);303
 _CRTIMP void   __cdecl qsort(void *, size_t, size_t, int (__cdecl *)
_CRTIMP void   __cdecl qsort(void *, size_t, size_t, int (__cdecl *)304
 (const void *, const void *));
        (const void *, const void *));305
 _CRTIMP int    __cdecl rand(void);
_CRTIMP int    __cdecl rand(void);306
 _CRTIMP void * __cdecl realloc(void *, size_t);
_CRTIMP void * __cdecl realloc(void *, size_t);307
 _CRTIMP int    __cdecl _set_error_mode(int);
_CRTIMP int    __cdecl _set_error_mode(int);308
 _CRTIMP void   __cdecl srand(unsigned int);
_CRTIMP void   __cdecl srand(unsigned int);309
 _CRTIMP double __cdecl strtod(const char *, char **);
_CRTIMP double __cdecl strtod(const char *, char **);310
 _CRTIMP long   __cdecl strtol(const char *, char **, int);
_CRTIMP long   __cdecl strtol(const char *, char **, int);311
 #ifdef  _M_M68K
#ifdef  _M_M68K312
 _CRTIMP long double __cdecl _strtold(const char *, char **);
_CRTIMP long double __cdecl _strtold(const char *, char **);313
 #endif
#endif314
 _CRTIMP unsigned long __cdecl strtoul(const char *, char **, int);
_CRTIMP unsigned long __cdecl strtoul(const char *, char **, int);315
 #ifndef _MAC
#ifndef _MAC316
 _CRTIMP int    __cdecl system(const char *);
_CRTIMP int    __cdecl system(const char *);317
 #endif
#endif318
 _CRTIMP char * __cdecl _ultoa(unsigned long, char *, int);
_CRTIMP char * __cdecl _ultoa(unsigned long, char *, int);319
 _CRTIMP int    __cdecl wctomb(char *, wchar_t);
_CRTIMP int    __cdecl wctomb(char *, wchar_t);320
 _CRTIMP size_t __cdecl wcstombs(char *, const wchar_t *, size_t);
_CRTIMP size_t __cdecl wcstombs(char *, const wchar_t *, size_t);321

322

323
 #ifndef _MAC
#ifndef _MAC324
 #ifndef _WSTDLIB_DEFINED
#ifndef _WSTDLIB_DEFINED325

326

 /**//* wide function prototypes, also declared in wchar.h  */
/**//* wide function prototypes, also declared in wchar.h  */327

328
 _CRTIMP wchar_t * __cdecl _itow (int, wchar_t *, int);
_CRTIMP wchar_t * __cdecl _itow (int, wchar_t *, int);329
 _CRTIMP wchar_t * __cdecl _ltow (long, wchar_t *, int);
_CRTIMP wchar_t * __cdecl _ltow (long, wchar_t *, int);330
 _CRTIMP wchar_t * __cdecl _ultow (unsigned long, wchar_t *, int);
_CRTIMP wchar_t * __cdecl _ultow (unsigned long, wchar_t *, int);331
 _CRTIMP double __cdecl wcstod(const wchar_t *, wchar_t **);
_CRTIMP double __cdecl wcstod(const wchar_t *, wchar_t **);332
 _CRTIMP long   __cdecl wcstol(const wchar_t *, wchar_t **, int);
_CRTIMP long   __cdecl wcstol(const wchar_t *, wchar_t **, int);333
 _CRTIMP unsigned long __cdecl wcstoul(const wchar_t *, wchar_t **, int);
_CRTIMP unsigned long __cdecl wcstoul(const wchar_t *, wchar_t **, int);334
 _CRTIMP wchar_t * __cdecl _wgetenv(const wchar_t *);
_CRTIMP wchar_t * __cdecl _wgetenv(const wchar_t *);335
 _CRTIMP int    __cdecl _wsystem(const wchar_t *);
_CRTIMP int    __cdecl _wsystem(const wchar_t *);336
 _CRTIMP int __cdecl _wtoi(const wchar_t *);
_CRTIMP int __cdecl _wtoi(const wchar_t *);337
 _CRTIMP long __cdecl _wtol(const wchar_t *);
_CRTIMP long __cdecl _wtol(const wchar_t *);338
 #if     _INTEGRAL_MAX_BITS >= 64
#if     _INTEGRAL_MAX_BITS >= 64339
 _CRTIMP wchar_t * __cdecl _i64tow(__int64, wchar_t *, int);
_CRTIMP wchar_t * __cdecl _i64tow(__int64, wchar_t *, int);340
 _CRTIMP wchar_t * __cdecl _ui64tow(unsigned __int64, wchar_t *, int);
_CRTIMP wchar_t * __cdecl _ui64tow(unsigned __int64, wchar_t *, int);341
 _CRTIMP __int64   __cdecl _wtoi64(const wchar_t *);
_CRTIMP __int64   __cdecl _wtoi64(const wchar_t *);342
 #endif
#endif343

344
 #define _WSTDLIB_DEFINED
#define _WSTDLIB_DEFINED345
 #endif
#endif346
 #endif  /* ndef _MAC */
#endif  /* ndef _MAC */347

348

349
 #ifndef _POSIX_
#ifndef _POSIX_350

351
 _CRTIMP char * __cdecl _ecvt(double, int, int *, int *);
_CRTIMP char * __cdecl _ecvt(double, int, int *, int *);352
 #if     _MSC_VER >= 1200
#if     _MSC_VER >= 1200353
 _CRTIMP __declspec(noreturn) void   __cdecl _exit(int);
_CRTIMP __declspec(noreturn) void   __cdecl _exit(int);354
 #else
#else355
 _CRTIMP void   __cdecl _exit(int);
_CRTIMP void   __cdecl _exit(int);356
 #endif
#endif357
 _CRTIMP char * __cdecl _fcvt(double, int, int *, int *);
_CRTIMP char * __cdecl _fcvt(double, int, int *, int *);358
 _CRTIMP char * __cdecl _fullpath(char *, const char *, size_t);
_CRTIMP char * __cdecl _fullpath(char *, const char *, size_t);359
 _CRTIMP char * __cdecl _gcvt(double, int, char *);
_CRTIMP char * __cdecl _gcvt(double, int, char *);360
 unsigned long __cdecl _lrotl(unsigned long, int);
        unsigned long __cdecl _lrotl(unsigned long, int);361
 unsigned long __cdecl _lrotr(unsigned long, int);
        unsigned long __cdecl _lrotr(unsigned long, int);362
 #ifndef _MAC
#ifndef _MAC363
 _CRTIMP void   __cdecl _makepath(char *, const char *, const char *, const char *,
_CRTIMP void   __cdecl _makepath(char *, const char *, const char *, const char *,364
 const char *);
        const char *);365
 #endif
#endif366
 _onexit_t __cdecl _onexit(_onexit_t);
        _onexit_t __cdecl _onexit(_onexit_t);367
 _CRTIMP void   __cdecl perror(const char *);
_CRTIMP void   __cdecl perror(const char *);368
 _CRTIMP int    __cdecl _putenv(const char *);
_CRTIMP int    __cdecl _putenv(const char *);369
 unsigned int __cdecl _rotl(unsigned int, int);
        unsigned int __cdecl _rotl(unsigned int, int);370
 unsigned int __cdecl _rotr(unsigned int, int);
        unsigned int __cdecl _rotr(unsigned int, int);371
 _CRTIMP void   __cdecl _searchenv(const char *, const char *, char *);
_CRTIMP void   __cdecl _searchenv(const char *, const char *, char *);372
 #ifndef _MAC
#ifndef _MAC373
 _CRTIMP void   __cdecl _splitpath(const char *, char *, char *, char *, char *);
_CRTIMP void   __cdecl _splitpath(const char *, char *, char *, char *, char *);374
 #endif
#endif375
 _CRTIMP void   __cdecl _swab(char *, char *, int);
_CRTIMP void   __cdecl _swab(char *, char *, int);376

377
 #ifndef _MAC
#ifndef _MAC378
 #ifndef _WSTDLIBP_DEFINED
#ifndef _WSTDLIBP_DEFINED379

380

 /**//* wide function prototypes, also declared in wchar.h  */
/**//* wide function prototypes, also declared in wchar.h  */381

382
 _CRTIMP wchar_t * __cdecl _wfullpath(wchar_t *, const wchar_t *, size_t);
_CRTIMP wchar_t * __cdecl _wfullpath(wchar_t *, const wchar_t *, size_t);383
 _CRTIMP void   __cdecl _wmakepath(wchar_t *, const wchar_t *, const wchar_t *, const wchar_t *,
_CRTIMP void   __cdecl _wmakepath(wchar_t *, const wchar_t *, const wchar_t *, const wchar_t *,384
 const wchar_t *);
        const wchar_t *);385
 _CRTIMP void   __cdecl _wperror(const wchar_t *);
_CRTIMP void   __cdecl _wperror(const wchar_t *);386
 _CRTIMP int    __cdecl _wputenv(const wchar_t *);
_CRTIMP int    __cdecl _wputenv(const wchar_t *);387
 _CRTIMP void   __cdecl _wsearchenv(const wchar_t *, const wchar_t *, wchar_t *);
_CRTIMP void   __cdecl _wsearchenv(const wchar_t *, const wchar_t *, wchar_t *);388
 _CRTIMP void   __cdecl _wsplitpath(const wchar_t *, wchar_t *, wchar_t *, wchar_t *, wchar_t *);
_CRTIMP void   __cdecl _wsplitpath(const wchar_t *, wchar_t *, wchar_t *, wchar_t *, wchar_t *);389

390
 #define _WSTDLIBP_DEFINED
#define _WSTDLIBP_DEFINED391
 #endif
#endif392
 #endif  /* ndef _MAC */
#endif  /* ndef _MAC */393

394

 /**//* --------- The following functions are OBSOLETE --------- */
/**//* --------- The following functions are OBSOLETE --------- */395

 /**//* The Win32 API SetErrorMode, Beep and Sleep should be used instead. */
/**//* The Win32 API SetErrorMode, Beep and Sleep should be used instead. */396
 #ifndef _MAC
#ifndef _MAC397
 _CRTIMP void __cdecl _seterrormode(int);
_CRTIMP void __cdecl _seterrormode(int);398
 _CRTIMP void __cdecl _beep(unsigned, unsigned);
_CRTIMP void __cdecl _beep(unsigned, unsigned);399
 _CRTIMP void __cdecl _sleep(unsigned long);
_CRTIMP void __cdecl _sleep(unsigned long);400
 #endif  /* ndef _MAC */
#endif  /* ndef _MAC */401

 /**//* --------- The preceding functions are OBSOLETE --------- */
/**//* --------- The preceding functions are OBSOLETE --------- */402

403
 #endif  /* _POSIX_ */
#endif  /* _POSIX_ */404

405

406
 #if     !__STDC__
#if     !__STDC__407

 /**//* --------- The declarations below should not be in stdlib.h --------- */
/**//* --------- The declarations below should not be in stdlib.h --------- */408

 /**//* --------- and will be removed in a future release. Include --------- */
/**//* --------- and will be removed in a future release. Include --------- */409

 /**//* --------- ctype.h to obtain these declarations.            --------- */
/**//* --------- ctype.h to obtain these declarations.            --------- */410

 #ifndef tolower     /**//* tolower has been undefined - use function */
#ifndef tolower     /**//* tolower has been undefined - use function */411
 _CRTIMP int __cdecl tolower(int);
_CRTIMP int __cdecl tolower(int);412
 #endif  /* tolower */
#endif  /* tolower */413

 #ifndef toupper     /**//* toupper has been undefined - use function */
#ifndef toupper     /**//* toupper has been undefined - use function */414
 _CRTIMP int __cdecl toupper(int);
_CRTIMP int __cdecl toupper(int);415
 #endif  /* toupper */
#endif  /* toupper */416

 /**//* --------- The declarations above will be removed.          --------- */
/**//* --------- The declarations above will be removed.          --------- */417
 #endif
#endif418

419

420
 #if     !__STDC__
#if     !__STDC__421

422
 #ifndef _POSIX_
#ifndef _POSIX_423

424

 /**//* Non-ANSI names for compatibility */
/**//* Non-ANSI names for compatibility */425

426
 #ifndef __cplusplus
#ifndef __cplusplus427
 #define max(a,b)    (((a) > (b)) ? (a) : (b))
#define max(a,b)    (((a) > (b)) ? (a) : (b))428
 #define min(a,b)    (((a) < (b)) ? (a) : (b))
#define min(a,b)    (((a) < (b)) ? (a) : (b))429
 #endif
#endif430

431
 #define sys_errlist _sys_errlist
#define sys_errlist _sys_errlist432
 #define sys_nerr    _sys_nerr
#define sys_nerr    _sys_nerr433
 #define environ     _environ
#define environ     _environ434

435
 _CRTIMP char * __cdecl ecvt(double, int, int *, int *);
_CRTIMP char * __cdecl ecvt(double, int, int *, int *);436
 _CRTIMP char * __cdecl fcvt(double, int, int *, int *);
_CRTIMP char * __cdecl fcvt(double, int, int *, int *);437
 _CRTIMP char * __cdecl gcvt(double, int, char *);
_CRTIMP char * __cdecl gcvt(double, int, char *);438
 _CRTIMP char * __cdecl itoa(int, char *, int);
_CRTIMP char * __cdecl itoa(int, char *, int);439
 _CRTIMP char * __cdecl ltoa(long, char *, int);
_CRTIMP char * __cdecl ltoa(long, char *, int);440
 onexit_t __cdecl onexit(onexit_t);
        onexit_t __cdecl onexit(onexit_t);441
 _CRTIMP int    __cdecl putenv(const char *);
_CRTIMP int    __cdecl putenv(const char *);442
 _CRTIMP void   __cdecl swab(char *, char *, int);
_CRTIMP void   __cdecl swab(char *, char *, int);443
 _CRTIMP char * __cdecl ultoa(unsigned long, char *, int);
_CRTIMP char * __cdecl ultoa(unsigned long, char *, int);444

445
 #endif  /* _POSIX_ */
#endif  /* _POSIX_ */446

447
 #endif  /* __STDC__ */
#endif  /* __STDC__ */448

449
 #ifdef  __cplusplus
#ifdef  __cplusplus450
 }
}451

452
 #endif
#endif453

454
 #ifdef  _MSC_VER
#ifdef  _MSC_VER455
 #pragma pack(pop)
#pragma pack(pop)456
 #endif  /* _MSC_VER */
#endif  /* _MSC_VER */457

458
 #endif  /* _INC_STDLIB */
#endif  /* _INC_STDLIB */459

==================================================
我们首先关注的内容是下面的代码:(第42------50行)
1
 /**//* Define _CRTIMP */
/**//* Define _CRTIMP */
2
3 #ifndef _CRTIMP
#ifndef _CRTIMP
4 #ifdef  _DLL
#ifdef  _DLL
5 #define _CRTIMP __declspec(dllimport)
#define _CRTIMP __declspec(dllimport)
6 #else   /* ndef _DLL */
#else   /* ndef _DLL */
7 #define _CRTIMP
#define _CRTIMP
8 #endif  /* _DLL */
#endif  /* _DLL */
9 #endif  /* _CRTIMP */
#endif  /* _CRTIMP */

 /**//* Define _CRTIMP */
/**//* Define _CRTIMP */2

3
 #ifndef _CRTIMP
#ifndef _CRTIMP4
 #ifdef  _DLL
#ifdef  _DLL5
 #define _CRTIMP __declspec(dllimport)
#define _CRTIMP __declspec(dllimport)6
 #else   /* ndef _DLL */
#else   /* ndef _DLL */7
 #define _CRTIMP
#define _CRTIMP8
 #endif  /* _DLL */
#endif  /* _DLL */9
 #endif  /* _CRTIMP */
#endif  /* _CRTIMP */ 
                    
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号