[XDK]
[reactos.git] / include / crt / inttypes.h
1 /**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the w64 mingw-runtime package.
4 * No warranty is given; refer to the file DISCLAIMER within this package.
5 */
6 /* 7.8 Format conversion of integer types <inttypes.h> */
7
8 #ifndef _INTTYPES_H_
9 #define _INTTYPES_H_
10
11 #include <crtdefs.h>
12 #include <stdint.h>
13 #define __need_wchar_t
14 #include <stddef.h>
15
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19
20 typedef struct {
21 intmax_t quot;
22 intmax_t rem;
23 } imaxdiv_t;
24
25 #if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)
26
27 /* 7.8.1 Macros for format specifiers
28 *
29 * MS runtime does not yet understand C9x standard "ll"
30 * length specifier. It appears to treat "ll" as "l".
31 * The non-standard I64 length specifier causes warning in GCC,
32 * but understood by MS runtime functions.
33 */
34
35 /* fprintf macros for signed types */
36 #define PRId8 "d"
37 #define PRId16 "d"
38 #define PRId32 "d"
39 #define PRId64 "I64d"
40
41 #define PRIdLEAST8 "d"
42 #define PRIdLEAST16 "d"
43 #define PRIdLEAST32 "d"
44 #define PRIdLEAST64 "I64d"
45
46 #define PRIdFAST8 "d"
47 #define PRIdFAST16 "d"
48 #define PRIdFAST32 "d"
49 #define PRIdFAST64 "I64d"
50
51 #define PRIdMAX "I64d"
52
53 #define PRIi8 "i"
54 #define PRIi16 "i"
55 #define PRIi32 "i"
56 #define PRIi64 "I64i"
57
58 #define PRIiLEAST8 "i"
59 #define PRIiLEAST16 "i"
60 #define PRIiLEAST32 "i"
61 #define PRIiLEAST64 "I64i"
62
63 #define PRIiFAST8 "i"
64 #define PRIiFAST16 "i"
65 #define PRIiFAST32 "i"
66 #define PRIiFAST64 "I64i"
67
68 #define PRIiMAX "I64i"
69
70 #define PRIo8 "o"
71 #define PRIo16 "o"
72 #define PRIo32 "o"
73 #define PRIo64 "I64o"
74
75 #define PRIoLEAST8 "o"
76 #define PRIoLEAST16 "o"
77 #define PRIoLEAST32 "o"
78 #define PRIoLEAST64 "I64o"
79
80 #define PRIoFAST8 "o"
81 #define PRIoFAST16 "o"
82 #define PRIoFAST32 "o"
83 #define PRIoFAST64 "I64o"
84
85 #define PRIoMAX "I64o"
86
87 /* fprintf macros for unsigned types */
88 #define PRIu8 "u"
89 #define PRIu16 "u"
90 #define PRIu32 "u"
91 #define PRIu64 "I64u"
92
93
94 #define PRIuLEAST8 "u"
95 #define PRIuLEAST16 "u"
96 #define PRIuLEAST32 "u"
97 #define PRIuLEAST64 "I64u"
98
99 #define PRIuFAST8 "u"
100 #define PRIuFAST16 "u"
101 #define PRIuFAST32 "u"
102 #define PRIuFAST64 "I64u"
103
104 #define PRIuMAX "I64u"
105
106 #define PRIx8 "x"
107 #define PRIx16 "x"
108 #define PRIx32 "x"
109 #define PRIx64 "I64x"
110
111 #define PRIxLEAST8 "x"
112 #define PRIxLEAST16 "x"
113 #define PRIxLEAST32 "x"
114 #define PRIxLEAST64 "I64x"
115
116 #define PRIxFAST8 "x"
117 #define PRIxFAST16 "x"
118 #define PRIxFAST32 "x"
119 #define PRIxFAST64 "I64x"
120
121 #define PRIxMAX "I64x"
122
123 #define PRIX8 "X"
124 #define PRIX16 "X"
125 #define PRIX32 "X"
126 #define PRIX64 "I64X"
127
128 #define PRIXLEAST8 "X"
129 #define PRIXLEAST16 "X"
130 #define PRIXLEAST32 "X"
131 #define PRIXLEAST64 "I64X"
132
133 #define PRIXFAST8 "X"
134 #define PRIXFAST16 "X"
135 #define PRIXFAST32 "X"
136 #define PRIXFAST64 "I64X"
137
138 #define PRIXMAX "I64X"
139
140 /*
141 * fscanf macros for signed int types
142 * NOTE: if 32-bit int is used for int_fast8_t and int_fast16_t
143 * (see stdint.h, 7.18.1.3), FAST8 and FAST16 should have
144 * no length identifiers
145 */
146
147 #define SCNd16 "hd"
148 #define SCNd32 "d"
149 #define SCNd64 "I64d"
150
151 #define SCNdLEAST16 "hd"
152 #define SCNdLEAST32 "d"
153 #define SCNdLEAST64 "I64d"
154
155 #define SCNdFAST16 "hd"
156 #define SCNdFAST32 "d"
157 #define SCNdFAST64 "I64d"
158
159 #define SCNdMAX "I64d"
160
161 #define SCNi16 "hi"
162 #define SCNi32 "i"
163 #define SCNi64 "I64i"
164
165 #define SCNiLEAST16 "hi"
166 #define SCNiLEAST32 "i"
167 #define SCNiLEAST64 "I64i"
168
169 #define SCNiFAST16 "hi"
170 #define SCNiFAST32 "i"
171 #define SCNiFAST64 "I64i"
172
173 #define SCNiMAX "I64i"
174
175 #define SCNo16 "ho"
176 #define SCNo32 "o"
177 #define SCNo64 "I64o"
178
179 #define SCNoLEAST16 "ho"
180 #define SCNoLEAST32 "o"
181 #define SCNoLEAST64 "I64o"
182
183 #define SCNoFAST16 "ho"
184 #define SCNoFAST32 "o"
185 #define SCNoFAST64 "I64o"
186
187 #define SCNoMAX "I64o"
188
189 #define SCNx16 "hx"
190 #define SCNx32 "x"
191 #define SCNx64 "I64x"
192
193 #define SCNxLEAST16 "hx"
194 #define SCNxLEAST32 "x"
195 #define SCNxLEAST64 "I64x"
196
197 #define SCNxFAST16 "hx"
198 #define SCNxFAST32 "x"
199 #define SCNxFAST64 "I64x"
200
201 #define SCNxMAX "I64x"
202
203 /* fscanf macros for unsigned int types */
204
205 #define SCNu16 "hu"
206 #define SCNu32 "u"
207 #define SCNu64 "I64u"
208
209 #define SCNuLEAST16 "hu"
210 #define SCNuLEAST32 "u"
211 #define SCNuLEAST64 "I64u"
212
213 #define SCNuFAST16 "hu"
214 #define SCNuFAST32 "u"
215 #define SCNuFAST64 "I64u"
216
217 #define SCNuMAX "I64u"
218
219 #ifdef _WIN64
220 #define PRIdPTR "I64d"
221 #define PRIiPTR "I64i"
222 #define PRIoPTR "I64o"
223 #define PRIuPTR "I64u"
224 #define PRIxPTR "I64x"
225 #define PRIXPTR "I64X"
226 #define SCNdPTR "I64d"
227 #define SCNiPTR "I64i"
228 #define SCNoPTR "I64o"
229 #define SCNxPTR "I64x"
230 #define SCNuPTR "I64u"
231 #else
232 #define PRIdPTR "d"
233 #define PRIiPTR "i"
234 #define PRIoPTR "o"
235 #define PRIuPTR "u"
236 #define PRIxPTR "x"
237 #define PRIXPTR "X"
238 #define SCNdPTR "d"
239 #define SCNiPTR "i"
240 #define SCNoPTR "o"
241 #define SCNxPTR "x"
242 #define SCNuPTR "u"
243 #endif
244
245 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
246 /*
247 * no length modifier for char types prior to C9x
248 * MS runtime scanf appears to treat "hh" as "h"
249 */
250
251 /* signed char */
252 #define SCNd8 "hhd"
253 #define SCNdLEAST8 "hhd"
254 #define SCNdFAST8 "hhd"
255
256 #define SCNi8 "hhi"
257 #define SCNiLEAST8 "hhi"
258 #define SCNiFAST8 "hhi"
259
260 #define SCNo8 "hho"
261 #define SCNoLEAST8 "hho"
262 #define SCNoFAST8 "hho"
263
264 #define SCNx8 "hhx"
265 #define SCNxLEAST8 "hhx"
266 #define SCNxFAST8 "hhx"
267
268 /* unsigned char */
269 #define SCNu8 "hhu"
270 #define SCNuLEAST8 "hhu"
271 #define SCNuFAST8 "hhu"
272 #endif /* __STDC_VERSION__ >= 199901 */
273
274 #endif /* !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) */
275
276 intmax_t __cdecl imaxabs (intmax_t j);
277 __CRT_INLINE intmax_t __cdecl imaxabs (intmax_t j)
278 {return (j >= 0 ? j : -j);}
279 imaxdiv_t __cdecl imaxdiv (intmax_t numer, intmax_t denom);
280
281 /* 7.8.2 Conversion functions for greatest-width integer types */
282
283 intmax_t __cdecl strtoimax (const char* __restrict__ nptr,
284 char** __restrict__ endptr, int base);
285 uintmax_t __cdecl strtoumax (const char* __restrict__ nptr,
286 char** __restrict__ endptr, int base);
287
288 intmax_t __cdecl wcstoimax (const wchar_t* __restrict__ nptr,
289 wchar_t** __restrict__ endptr, int base);
290 uintmax_t __cdecl wcstoumax (const wchar_t* __restrict__ nptr,
291 wchar_t** __restrict__ endptr, int base);
292
293 #ifdef __cplusplus
294 }
295 #endif
296
297 #endif /* ndef _INTTYPES_H */