Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
src
icl_core
src
icl_core
msvc_inttypes.h
Go to the documentation of this file.
1
// -- BEGIN LICENSE BLOCK ----------------------------------------------
2
// This file is part of FZIs ic_workspace.
3
//
4
// This program is free software licensed under the LGPL
5
// (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
6
// You can find a copy of this license in LICENSE folder in the top
7
// directory of the source code.
8
//
9
// © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
10
//
11
// -- END LICENSE BLOCK ------------------------------------------------
12
13
// ISO C9x compliant inttypes.h for Microsoft Visual Studio
14
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
15
//
16
// Copyright (c) 2006 Alexander Chemeris
17
//
18
// Redistribution and use in source and binary forms, with or without
19
// modification, are permitted provided that the following conditions are met:
20
//
21
// 1. Redistributions of source code must retain the above copyright notice,
22
// this list of conditions and the following disclaimer.
23
//
24
// 2. Redistributions in binary form must reproduce the above copyright
25
// notice, this list of conditions and the following disclaimer in the
26
// documentation and/or other materials provided with the distribution.
27
//
28
// 3. The name of the author may be used to endorse or promote products
29
// derived from this software without specific prior written permission.
30
//
31
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
32
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
33
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
34
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
37
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
38
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
39
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
40
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
//
43
44
#ifndef _MSC_VER // [
45
#error "Use this header only with Microsoft Visual C++ compilers!"
46
#endif // _MSC_VER ]
47
48
#ifndef _MSC_INTTYPES_H_ // [
49
#define _MSC_INTTYPES_H_
50
51
#if _MSC_VER > 1000
52
#pragma once
53
#endif
54
55
#include "
icl_core/msvc_stdint.h
"
56
57
// 7.8 Format conversion of integer types
58
59
typedef
struct
60
{
61
intmax_t
quot
;
62
intmax_t
rem
;
63
}
imaxdiv_t
;
64
65
// 7.8.1 Macros for format specifiers
66
67
#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198
68
69
// The fprintf macros for signed integers are:
70
#define PRId8 "d"
71
#define PRIi8 "i"
72
#define PRIdLEAST8 "d"
73
#define PRIiLEAST8 "i"
74
#define PRIdFAST8 "d"
75
#define PRIiFAST8 "i"
76
77
#define PRId16 "hd"
78
#define PRIi16 "hi"
79
#define PRIdLEAST16 "hd"
80
#define PRIiLEAST16 "hi"
81
#define PRIdFAST16 "hd"
82
#define PRIiFAST16 "hi"
83
84
#define PRId32 "I32d"
85
#define PRIi32 "I32i"
86
#define PRIdLEAST32 "I32d"
87
#define PRIiLEAST32 "I32i"
88
#define PRIdFAST32 "I32d"
89
#define PRIiFAST32 "I32i"
90
91
#define PRId64 "I64d"
92
#define PRIi64 "I64i"
93
#define PRIdLEAST64 "I64d"
94
#define PRIiLEAST64 "I64i"
95
#define PRIdFAST64 "I64d"
96
#define PRIiFAST64 "I64i"
97
98
#define PRIdMAX "I64d"
99
#define PRIiMAX "I64i"
100
101
#define PRIdPTR "Id"
102
#define PRIiPTR "Ii"
103
104
// The fprintf macros for unsigned integers are:
105
#define PRIo8 "o"
106
#define PRIu8 "u"
107
#define PRIx8 "x"
108
#define PRIX8 "X"
109
#define PRIoLEAST8 "o"
110
#define PRIuLEAST8 "u"
111
#define PRIxLEAST8 "x"
112
#define PRIXLEAST8 "X"
113
#define PRIoFAST8 "o"
114
#define PRIuFAST8 "u"
115
#define PRIxFAST8 "x"
116
#define PRIXFAST8 "X"
117
118
#define PRIo16 "ho"
119
#define PRIu16 "hu"
120
#define PRIx16 "hx"
121
#define PRIX16 "hX"
122
#define PRIoLEAST16 "ho"
123
#define PRIuLEAST16 "hu"
124
#define PRIxLEAST16 "hx"
125
#define PRIXLEAST16 "hX"
126
#define PRIoFAST16 "ho"
127
#define PRIuFAST16 "hu"
128
#define PRIxFAST16 "hx"
129
#define PRIXFAST16 "hX"
130
131
#define PRIo32 "I32o"
132
#define PRIu32 "I32u"
133
#define PRIx32 "I32x"
134
#define PRIX32 "I32X"
135
#define PRIoLEAST32 "I32o"
136
#define PRIuLEAST32 "I32u"
137
#define PRIxLEAST32 "I32x"
138
#define PRIXLEAST32 "I32X"
139
#define PRIoFAST32 "I32o"
140
#define PRIuFAST32 "I32u"
141
#define PRIxFAST32 "I32x"
142
#define PRIXFAST32 "I32X"
143
144
#define PRIo64 "I64o"
145
#define PRIu64 "I64u"
146
#define PRIx64 "I64x"
147
#define PRIX64 "I64X"
148
#define PRIoLEAST64 "I64o"
149
#define PRIuLEAST64 "I64u"
150
#define PRIxLEAST64 "I64x"
151
#define PRIXLEAST64 "I64X"
152
#define PRIoFAST64 "I64o"
153
#define PRIuFAST64 "I64u"
154
#define PRIxFAST64 "I64x"
155
#define PRIXFAST64 "I64X"
156
157
#define PRIoMAX "I64o"
158
#define PRIuMAX "I64u"
159
#define PRIxMAX "I64x"
160
#define PRIXMAX "I64X"
161
162
#define PRIoPTR "Io"
163
#define PRIuPTR "Iu"
164
#define PRIxPTR "Ix"
165
#define PRIXPTR "IX"
166
167
// The fscanf macros for signed integers are:
168
#define SCNd8 "d"
169
#define SCNi8 "i"
170
#define SCNdLEAST8 "d"
171
#define SCNiLEAST8 "i"
172
#define SCNdFAST8 "d"
173
#define SCNiFAST8 "i"
174
175
#define SCNd16 "hd"
176
#define SCNi16 "hi"
177
#define SCNdLEAST16 "hd"
178
#define SCNiLEAST16 "hi"
179
#define SCNdFAST16 "hd"
180
#define SCNiFAST16 "hi"
181
182
#define SCNd32 "ld"
183
#define SCNi32 "li"
184
#define SCNdLEAST32 "ld"
185
#define SCNiLEAST32 "li"
186
#define SCNdFAST32 "ld"
187
#define SCNiFAST32 "li"
188
189
#define SCNd64 "I64d"
190
#define SCNi64 "I64i"
191
#define SCNdLEAST64 "I64d"
192
#define SCNiLEAST64 "I64i"
193
#define SCNdFAST64 "I64d"
194
#define SCNiFAST64 "I64i"
195
196
#define SCNdMAX "I64d"
197
#define SCNiMAX "I64i"
198
199
#ifdef _WIN64 // [
200
# define SCNdPTR "I64d"
201
# define SCNiPTR "I64i"
202
#else // _WIN64 ][
203
# define SCNdPTR "ld"
204
# define SCNiPTR "li"
205
#endif // _WIN64 ]
206
207
// The fscanf macros for unsigned integers are:
208
#define SCNo8 "o"
209
#define SCNu8 "u"
210
#define SCNx8 "x"
211
#define SCNX8 "X"
212
#define SCNoLEAST8 "o"
213
#define SCNuLEAST8 "u"
214
#define SCNxLEAST8 "x"
215
#define SCNXLEAST8 "X"
216
#define SCNoFAST8 "o"
217
#define SCNuFAST8 "u"
218
#define SCNxFAST8 "x"
219
#define SCNXFAST8 "X"
220
221
#define SCNo16 "ho"
222
#define SCNu16 "hu"
223
#define SCNx16 "hx"
224
#define SCNX16 "hX"
225
#define SCNoLEAST16 "ho"
226
#define SCNuLEAST16 "hu"
227
#define SCNxLEAST16 "hx"
228
#define SCNXLEAST16 "hX"
229
#define SCNoFAST16 "ho"
230
#define SCNuFAST16 "hu"
231
#define SCNxFAST16 "hx"
232
#define SCNXFAST16 "hX"
233
234
#define SCNo32 "lo"
235
#define SCNu32 "lu"
236
#define SCNx32 "lx"
237
#define SCNX32 "lX"
238
#define SCNoLEAST32 "lo"
239
#define SCNuLEAST32 "lu"
240
#define SCNxLEAST32 "lx"
241
#define SCNXLEAST32 "lX"
242
#define SCNoFAST32 "lo"
243
#define SCNuFAST32 "lu"
244
#define SCNxFAST32 "lx"
245
#define SCNXFAST32 "lX"
246
247
#define SCNo64 "I64o"
248
#define SCNu64 "I64u"
249
#define SCNx64 "I64x"
250
#define SCNX64 "I64X"
251
#define SCNoLEAST64 "I64o"
252
#define SCNuLEAST64 "I64u"
253
#define SCNxLEAST64 "I64x"
254
#define SCNXLEAST64 "I64X"
255
#define SCNoFAST64 "I64o"
256
#define SCNuFAST64 "I64u"
257
#define SCNxFAST64 "I64x"
258
#define SCNXFAST64 "I64X"
259
260
#define SCNoMAX "I64o"
261
#define SCNuMAX "I64u"
262
#define SCNxMAX "I64x"
263
#define SCNXMAX "I64X"
264
265
#ifdef _WIN64 // [
266
# define SCNoPTR "I64o"
267
# define SCNuPTR "I64u"
268
# define SCNxPTR "I64x"
269
# define SCNXPTR "I64X"
270
#else // _WIN64 ][
271
# define SCNoPTR "lo"
272
# define SCNuPTR "lu"
273
# define SCNxPTR "lx"
274
# define SCNXPTR "lX"
275
#endif // _WIN64 ]
276
277
#endif // __STDC_FORMAT_MACROS ]
278
279
// 7.8.2 Functions for greatest-width integer types
280
281
// 7.8.2.1 The imaxabs function
282
#define imaxabs _abs64
283
284
// 7.8.2.2 The imaxdiv function
285
286
// This is modified version of div() function from Microsoft's div.c found
287
// in %MSVC.NET%\crt\src\div.c
288
#ifdef STATIC_IMAXDIV // [
289
static
290
#else // STATIC_IMAXDIV ][
291
_inline
292
#endif // STATIC_IMAXDIV ]
293
imaxdiv_t
__cdecl
imaxdiv
(
intmax_t
numer,
intmax_t
denom)
294
{
295
imaxdiv_t
result;
296
297
result.
quot
= numer / denom;
298
result.
rem
= numer % denom;
299
300
if
(numer < 0 && result.rem > 0)
301
{
302
// did division wrong; must fix up
303
++result.
quot
;
304
result.
rem
-= denom;
305
}
306
307
return
result;
308
}
309
310
// 7.8.2.3 The strtoimax and strtoumax functions
311
#define strtoimax _strtoi64
312
#define strtoumax _strtoui64
313
314
// 7.8.2.4 The wcstoimax and wcstoumax functions
315
#define wcstoimax _wcstoi64
316
#define wcstoumax _wcstoui64
317
318
319
#endif // _MSC_INTTYPES_H_ ]
imaxdiv_t
Definition:
msvc_inttypes.h:59
msvc_stdint.h
intmax_t
int64_t intmax_t
Definition:
msvc_stdint.h:137
imaxdiv_t::rem
intmax_t rem
Definition:
msvc_inttypes.h:62
imaxdiv_t::quot
intmax_t quot
Definition:
msvc_inttypes.h:61
imaxdiv
_inline imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
Definition:
msvc_inttypes.h:293
fzi_icl_core
Author(s):
autogenerated on Mon Jun 10 2019 13:17:58