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