Reverted latest changes.
[reactos.git] / reactos / include / msvcrt / stddef.h
1 /*
2 * stddef.h
3 *
4 * Standard type definitions provided by the C library.
5 *
6 * NOTE: Actually supplied by the compiler (correct?). As such, GCC
7 * supplies a version of this header file. Unfortunately, GCC's
8 * version is all tied up with the way other headers for the
9 * GNU C library are implemented (or vice-versa), in a similar
10 * way to how the other Mingw32 headers are dependent on
11 * certain internals of this file. It is not clear to me whether
12 * you can safely use the GCC version in place of this version.
13 * TODO: Line up usage in other header files to work with GCC
14 * stddef.h.
15 *
16 * This file is part of the Mingw32 package.
17 *
18 * Contributors:
19 * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
20 *
21 * THIS SOFTWARE IS NOT COPYRIGHTED
22 *
23 * This source code is offered for use in the public domain. You may
24 * use, modify or distribute it freely.
25 *
26 * This code is distributed in the hope that it will be useful but
27 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
28 * DISCLAMED. This includes but is not limited to warranties of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
30 *
31 * $Revision: 1.5 $
32 * $Author: chorns $
33 * $Date: 2002/09/08 10:22:31 $
34 *
35 */
36
37
38 #ifndef __MSVCRT_STDDEF_H_
39
40 /*
41 * Any one of these symbols __need_* means that a standard header file
42 * wants us just to define one data type. So don't define
43 * the symbols that indicate this file's entire job has been done.
44 */
45 #if (!defined(__need_wchar_t) && !defined(__need_wint_t) \
46 && !defined(__need_size_t) && !defined(__need_ptrdiff_t) \
47 && !defined(__need_NULL))
48 #define __MSVCRT_STDDEF_H_
49 #endif
50
51 /*
52 * NOTE: The following typedefs are done using __xxx_TYPE__ defines followed
53 * by typedefs using those defines. I have chosen to do it this way because
54 * GCC supplies definitions for __xxx_TYPE__ macros and if, for example, your
55 * size_t is typedef'ed differently from what GCC expects it will give you
56 * warnings when you prototype functions like memcmp and memcpy. The values
57 * for __xxx_TYPE__ in this header file are the same as those given by GCC.
58 * Those values appear to work with the MSVCRT functions.
59 */
60
61 /*
62 * Signed type of difference of two pointers.
63 */
64
65 /* Define this type if we are doing the whole job, or if we want this type
66 * in particular. */
67 #if defined (__MSVCRT_STDDEF_H_) || defined (__need_ptrdiff_t)
68
69 #ifndef _PTRDIFF_T_
70 #define _PTRDIFF_T_
71 #ifndef __PTRDIFF_TYPE__
72 #define __PTRDIFF_TYPE__ int
73 #endif
74 typedef __PTRDIFF_TYPE__ ptrdiff_t;
75 #endif
76
77 /* If this symbol has done its job, get rid of it. */
78 #undef __need_ptrdiff_t
79
80 #endif /* __MSVCRT_STDDEF_H_ or __need_ptrdiff_t. */
81
82 /*
83 * Unsigned type of `sizeof' something.
84 */
85
86
87 /* Define this type if we are doing the whole job,
88 * or if we want this type in particular. */
89 #if defined (__MSVCRT_STDDEF_H_) || defined (__need_size_t)
90
91 #ifndef _SIZE_T_
92 #define _SIZE_T_
93 #define SIZE_T_DEFINED
94 #define _SIZE_T
95 #ifndef __SIZE_TYPE__
96 #define __SIZE_TYPE__ unsigned int
97 #endif
98 typedef __SIZE_TYPE__ size_t;
99 #endif
100
101 #undef __need_size_t
102
103 #endif /* __MSVCRT_STDDEF_H_ or __need_size_t. */
104
105 /* Wide character type.
106 Locale-writers should change this as necessary to
107 be big enough to hold unique values not between 0 and 127,
108 and not (wchar_t) -1, for each defined multibyte character. */
109
110 /* Define this type if we are doing the whole job,
111 or if we want this type in particular. */
112 #if defined (__MSVCRT_STDDEF_H_) || defined (__need_wchar_t)
113
114 #ifndef _WCHAR_T_
115 #define _WCHAR_T_
116 #define _WCHAR_T
117 #define _WCHAR_T_DEFINED
118 #ifndef __WCHAR_TYPE__
119 #define __WCHAR_TYPE__ short unsigned int
120 #endif
121 #ifndef __cplusplus
122 typedef __WCHAR_TYPE__ wchar_t;
123 #endif /* C++ */
124 #endif /* wchar_t not already defined */
125
126 #undef __need_wchar_t
127
128 #endif /* __MSVCRT_STDDEF_H_ or __need_wchar_t. */
129
130 /*
131 * wint_t, the equivalent of int in wchar ctype functions.
132 */
133 #if defined (__MSVCRT_STDDEF_H_) || defined (__need_wint_t)
134
135 #ifndef _WINT_T_
136 #define _WINT_T_
137 #define _WINT_T /* To satisfy libstdc++ */
138 #ifndef __WINT_TYPE__
139 #define __WINT_TYPE__ short int
140 #endif /* Not defined __WINT_TYPE__ */
141
142 typedef __WINT_TYPE__ wint_t;
143 #endif /* Not defined _WINT_T_ */
144
145 #undef __need_wint_t
146
147 #endif /* __MSVCRT_STDDEF_H_ or __need_wint_t. */
148
149
150 /*
151 * A null pointer constant.
152 */
153
154 #if defined (__MSVCRT_STDDEF_H_) || defined (__need_NULL)
155
156 #undef NULL
157 #define NULL (0)
158 #endif /* __MSVCRT_STDDEF_H_ or __need_NULL */
159
160 #undef __need_NULL
161
162
163 /*
164 * Offsetof, a macro for finding the offset of a member in a structure.
165 * Works by returning the 'address' of the MEMBER of a TYPE struct at address
166 * zero.
167 */
168
169 #if defined (__MSVCRT_STDDEF_H_)
170 #define offsetof(TYPE, MEMBER) ((size_t) &( ((TYPE *) 0)->MEMBER ))
171 #endif /* __MSVCRT_STDDEF_H_ */
172
173
174 #endif /* not __MSVCRT_STDDEF_H_ */