comparison stdint.h @ 0:85c12d7e8144

Initial check in.
author alexander.chemeris@d525d15b-5824-0410-80a3-6185d19c2cde
date Mon, 11 Dec 2006 18:39:27 +0000
parents
children 45fb2c2960e1
comparison
equal deleted inserted replaced
-1:000000000000 0:85c12d7e8144
1 // ISO C9x compliant inttypes.h for Miscrosoft Visual Studio
2 // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
3 //
4 // Copyright (c) 2006 Alexander Chemeris
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 ///////////////////////////////////////////////////////////////////////////////
20
21 // This file is only usable with Microsoft Visual Studio 2003 or later.
22 #ifdef _MSC_VER // [
23
24 #ifndef _MSC_STDINT_H_ // [
25 #define _MSC_STDINT_H_
26
27 #if _MSC_VER > 1000
28 #pragma once
29 #endif
30
31 #include <BaseTsd.h>
32
33 // 7.18.1 Integer types
34
35 // 7.18.1.1 Exact-width integer types
36 typedef INT8 int8_t;
37 typedef INT16 int16_t;
38 typedef INT32 int32_t; // There is LONG32 type defined the same. Should it be used here?
39 typedef INT64 int64_t; // There is LONG64 type defined the same. Should it be used here?
40 typedef UINT8 uint8_t;
41 typedef UINT16 uint16_t;
42 typedef UINT32 uint32_t; // There are ULONG32 and DWORD32 type defined the same. Should one of them be used here?
43 typedef UINT64 uint64_t; // There are ULONG64 and DWORD64 type defined the same. Should one of them be used here?
44
45 // 7.18.1.2 Minimum-width integer types
46 typedef int8_t int_least8_t;
47 typedef int16_t int_least16_t;
48 typedef int32_t int_least32_t;
49 typedef int64_t int_least64_t;
50 typedef uint8_t uint_least8_t;
51 typedef uint16_t uint_least16_t;
52 typedef uint32_t uint_least32_t;
53 typedef uint64_t uint_least64_t;
54
55 // 7.18.1.3 Fastest minimum-width integer types
56 typedef int8_t int_fast8_t;
57 typedef int16_t int_fast16_t;
58 typedef int32_t int_fast32_t;
59 typedef int64_t int_fast64_t;
60 typedef uint8_t uint_fast8_t;
61 typedef uint16_t uint_fast16_t;
62 typedef uint32_t uint_fast32_t;
63 typedef uint64_t uint_fast64_t;
64
65 // 7.18.1.4 Integer types capable of holding object pointers
66 typedef INT_PTR intptr_t;
67 typedef UINT_PTR uintptr_t;
68
69 // 7.18.1.5 Greatest-width integer types
70 typedef int64_t intmax_t;
71 typedef uint64_t uintmax_t;
72
73
74 // 7.18.2 Limits of specified-width integer types
75
76 #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
77
78 // 7.18.2.1 Limits of exact-width integer types
79 #define INT8_MIN _I8_MIN
80 #define INT8_MAX _I8_MAX
81 #define INT16_MIN _I16_MIN
82 #define INT16_MAX _I16_MAX
83 #define INT32_MIN _I32_MIN
84 #define INT32_MAX _I32_MAX
85 #define INT64_MIN _I64_MIN
86 #define INT64_MAX _I64_MAX
87 #define UINT8_MAX _UI8_MAX
88 #define UINT16_MAX _UI16_MAX
89 #define UINT32_MAX _UI32_MAX
90 #define UINT64_MAX _UI64_MAX
91
92 // 7.18.2.2 Limits of minimum-width integer types
93 #define INT_LEAST8_MIN INT8_MIN
94 #define INT_LEAST8_MAX INT8_MAX
95 #define INT_LEAST16_MIN INT16_MIN
96 #define INT_LEAST16_MAX INT16_MAX
97 #define INT_LEAST32_MIN INT32_MIN
98 #define INT_LEAST32_MAX INT32_MAX
99 #define INT_LEAST64_MIN INT64_MIN
100 #define INT_LEAST64_MAX INT64_MAX
101 #define UINT_LEAST8_MAX UINT8_MAX
102 #define UINT_LEAST16_MAX UINT16_MAX
103 #define UINT_LEAST32_MAX UINT32_MAX
104 #define UINT_LEAST64_MAX UINT64_MAX
105
106 // 7.18.2.3 Limits of fastest minimum-width integer types
107 #define INT_FAST8_MIN INT8_MIN
108 #define INT_FAST8_MAX INT8_MAX
109 #define INT_FAST16_MIN INT16_MIN
110 #define INT_FAST16_MAX INT16_MAX
111 #define INT_FAST32_MIN INT32_MIN
112 #define INT_FAST32_MAX INT32_MAX
113 #define INT_FAST64_MIN INT64_MIN
114 #define INT_FAST64_MAX INT64_MAX
115 #define UINT_FAST8_MAX UINT8_MAX
116 #define UINT_FAST16_MAX UINT16_MAX
117 #define UINT_FAST32_MAX UINT32_MAX
118 #define UINT_FAST64_MAX UINT64_MAX
119
120 // 7.18.2.4 Limits of integer types capable of holding object pointers
121 #ifdef _WIN64 // [
122 # define INTPTR_MIN INT32_MIN
123 # define INTPTR_MAX INT32_MAX
124 # define UINTPTR_MAX UINT32_MAX
125 #else // _WIN64 ][
126 # define INTPTR_MIN INT64_MIN
127 # define INTPTR_MAX INT64_MAX
128 # define UINTPTR_MAX UINT64_MAX
129 #endif // _WIN64 ]
130
131 // 7.18.2.5 Limits of greatest-width integer types
132 #define INTMAX_MIN INT64_MIN
133 #define INTMAX_MAX INT64_MAX
134 #define UINTMAX_MAX UINT64_MAX
135
136 // 7.18.3 Limits of other integer types
137
138 #ifdef _WIN64 // [
139 # define PTRDIFF_MIN _I64_MIN
140 # define PTRDIFF_MAX _I64_MAX
141 #else // _WIN64 ][
142 # define PTRDIFF_MIN _I32_MIN
143 # define PTRDIFF_MAX _I32_MAX
144 #endif // _WIN64 ]
145
146 #define SIG_ATOMIC_MIN INT_MIN
147 #define SIG_ATOMIC_MAX INT_MAX
148
149 #ifdef _WIN64 // [
150 # define SIZE_MAX _UI64_MAX
151 #else // _WIN64 ][
152 # define SIZE_MAX _UI32_MAX
153 #endif // _WIN64 ]
154
155 // WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
156 #ifndef WCHAR_MIN // [
157 #define WCHAR_MIN 0
158 #endif // WCHAR_MIN ]
159 #ifndef WCHAR_MAX // [
160 #define WCHAR_MAX _UI16_MAX
161 #endif // WCHAR_MAX ]
162
163 #define WINT_MIN 0
164 #define WINT_MAX _UI16_MAX
165
166 #endif // __STDC_LIMIT_MACROS ]
167
168
169 // 7.18.4 Limits of other integer types
170
171 #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
172
173 // 7.18.4.1 Macros for minimum-width integer constants
174
175 #define INT8_C(val) val
176 #define INT16_C(val) val
177 #define INT32_C(val) val##L
178 #define INT64_C(val) val##i64
179
180 #define UINT8_C(val) val
181 #define UINT16_C(val) val
182 #define UINT32_C(val) val##UL
183 #define UINT64_C(val) val##Ui64
184
185 // 7.18.4.2 Macros for greatest-width integer constants
186 #define INTMAX_C INT64_C
187 #define UINTMAX_C UINT64_C
188
189 #endif // __STDC_CONSTANT_MACROS ]
190
191
192
193 #endif // _MSC_STDINT_H_ ]
194
195 #endif // _MSC_VER ]