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