msvc_inttypes.h
Go to the documentation of this file.
00001 // ISO C9x  compliant inttypes.h for Microsoft Visual Studio
00002 // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
00003 //
00004 //  Copyright (c) 2006 Alexander Chemeris
00005 //
00006 // Redistribution and use in source and binary forms, with or without
00007 // modification, are permitted provided that the following conditions are met:
00008 //
00009 //   1. Redistributions of source code must retain the above copyright notice,
00010 //      this list of conditions and the following disclaimer.
00011 //
00012 //   2. Redistributions in binary form must reproduce the above copyright
00013 //      notice, this list of conditions and the following disclaimer in the
00014 //      documentation and/or other materials provided with the distribution.
00015 //
00016 //   3. The name of the author may be used to endorse or promote products
00017 //      derived from this software without specific prior written permission.
00018 //
00019 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
00020 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00021 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
00022 // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00023 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00024 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00025 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00026 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00027 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00028 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 //
00031 
00032 #ifndef _MSC_VER // [
00033 #error "Use this header only with Microsoft Visual C++ compilers!"
00034 #endif // _MSC_VER ]
00035 
00036 #ifndef _MSC_INTTYPES_H_ // [
00037 #define _MSC_INTTYPES_H_
00038 
00039 #if _MSC_VER > 1000
00040 #pragma once
00041 #endif
00042 
00043 #include "icl_core/msvc_stdint.h"
00044 
00045 // 7.8 Format conversion of integer types
00046 
00047 typedef struct
00048 {
00049    intmax_t quot;
00050    intmax_t rem;
00051 } imaxdiv_t;
00052 
00053 // 7.8.1 Macros for format specifiers
00054 
00055 #if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [   See footnote 185 at page 198
00056 
00057 // The fprintf macros for signed integers are:
00058 #define PRId8       "d"
00059 #define PRIi8       "i"
00060 #define PRIdLEAST8  "d"
00061 #define PRIiLEAST8  "i"
00062 #define PRIdFAST8   "d"
00063 #define PRIiFAST8   "i"
00064 
00065 #define PRId16       "hd"
00066 #define PRIi16       "hi"
00067 #define PRIdLEAST16  "hd"
00068 #define PRIiLEAST16  "hi"
00069 #define PRIdFAST16   "hd"
00070 #define PRIiFAST16   "hi"
00071 
00072 #define PRId32       "I32d"
00073 #define PRIi32       "I32i"
00074 #define PRIdLEAST32  "I32d"
00075 #define PRIiLEAST32  "I32i"
00076 #define PRIdFAST32   "I32d"
00077 #define PRIiFAST32   "I32i"
00078 
00079 #define PRId64       "I64d"
00080 #define PRIi64       "I64i"
00081 #define PRIdLEAST64  "I64d"
00082 #define PRIiLEAST64  "I64i"
00083 #define PRIdFAST64   "I64d"
00084 #define PRIiFAST64   "I64i"
00085 
00086 #define PRIdMAX     "I64d"
00087 #define PRIiMAX     "I64i"
00088 
00089 #define PRIdPTR     "Id"
00090 #define PRIiPTR     "Ii"
00091 
00092 // The fprintf macros for unsigned integers are:
00093 #define PRIo8       "o"
00094 #define PRIu8       "u"
00095 #define PRIx8       "x"
00096 #define PRIX8       "X"
00097 #define PRIoLEAST8  "o"
00098 #define PRIuLEAST8  "u"
00099 #define PRIxLEAST8  "x"
00100 #define PRIXLEAST8  "X"
00101 #define PRIoFAST8   "o"
00102 #define PRIuFAST8   "u"
00103 #define PRIxFAST8   "x"
00104 #define PRIXFAST8   "X"
00105 
00106 #define PRIo16       "ho"
00107 #define PRIu16       "hu"
00108 #define PRIx16       "hx"
00109 #define PRIX16       "hX"
00110 #define PRIoLEAST16  "ho"
00111 #define PRIuLEAST16  "hu"
00112 #define PRIxLEAST16  "hx"
00113 #define PRIXLEAST16  "hX"
00114 #define PRIoFAST16   "ho"
00115 #define PRIuFAST16   "hu"
00116 #define PRIxFAST16   "hx"
00117 #define PRIXFAST16   "hX"
00118 
00119 #define PRIo32       "I32o"
00120 #define PRIu32       "I32u"
00121 #define PRIx32       "I32x"
00122 #define PRIX32       "I32X"
00123 #define PRIoLEAST32  "I32o"
00124 #define PRIuLEAST32  "I32u"
00125 #define PRIxLEAST32  "I32x"
00126 #define PRIXLEAST32  "I32X"
00127 #define PRIoFAST32   "I32o"
00128 #define PRIuFAST32   "I32u"
00129 #define PRIxFAST32   "I32x"
00130 #define PRIXFAST32   "I32X"
00131 
00132 #define PRIo64       "I64o"
00133 #define PRIu64       "I64u"
00134 #define PRIx64       "I64x"
00135 #define PRIX64       "I64X"
00136 #define PRIoLEAST64  "I64o"
00137 #define PRIuLEAST64  "I64u"
00138 #define PRIxLEAST64  "I64x"
00139 #define PRIXLEAST64  "I64X"
00140 #define PRIoFAST64   "I64o"
00141 #define PRIuFAST64   "I64u"
00142 #define PRIxFAST64   "I64x"
00143 #define PRIXFAST64   "I64X"
00144 
00145 #define PRIoMAX     "I64o"
00146 #define PRIuMAX     "I64u"
00147 #define PRIxMAX     "I64x"
00148 #define PRIXMAX     "I64X"
00149 
00150 #define PRIoPTR     "Io"
00151 #define PRIuPTR     "Iu"
00152 #define PRIxPTR     "Ix"
00153 #define PRIXPTR     "IX"
00154 
00155 // The fscanf macros for signed integers are:
00156 #define SCNd8       "d"
00157 #define SCNi8       "i"
00158 #define SCNdLEAST8  "d"
00159 #define SCNiLEAST8  "i"
00160 #define SCNdFAST8   "d"
00161 #define SCNiFAST8   "i"
00162 
00163 #define SCNd16       "hd"
00164 #define SCNi16       "hi"
00165 #define SCNdLEAST16  "hd"
00166 #define SCNiLEAST16  "hi"
00167 #define SCNdFAST16   "hd"
00168 #define SCNiFAST16   "hi"
00169 
00170 #define SCNd32       "ld"
00171 #define SCNi32       "li"
00172 #define SCNdLEAST32  "ld"
00173 #define SCNiLEAST32  "li"
00174 #define SCNdFAST32   "ld"
00175 #define SCNiFAST32   "li"
00176 
00177 #define SCNd64       "I64d"
00178 #define SCNi64       "I64i"
00179 #define SCNdLEAST64  "I64d"
00180 #define SCNiLEAST64  "I64i"
00181 #define SCNdFAST64   "I64d"
00182 #define SCNiFAST64   "I64i"
00183 
00184 #define SCNdMAX     "I64d"
00185 #define SCNiMAX     "I64i"
00186 
00187 #ifdef _WIN64 // [
00188 #  define SCNdPTR     "I64d"
00189 #  define SCNiPTR     "I64i"
00190 #else  // _WIN64 ][
00191 #  define SCNdPTR     "ld"
00192 #  define SCNiPTR     "li"
00193 #endif  // _WIN64 ]
00194 
00195 // The fscanf macros for unsigned integers are:
00196 #define SCNo8       "o"
00197 #define SCNu8       "u"
00198 #define SCNx8       "x"
00199 #define SCNX8       "X"
00200 #define SCNoLEAST8  "o"
00201 #define SCNuLEAST8  "u"
00202 #define SCNxLEAST8  "x"
00203 #define SCNXLEAST8  "X"
00204 #define SCNoFAST8   "o"
00205 #define SCNuFAST8   "u"
00206 #define SCNxFAST8   "x"
00207 #define SCNXFAST8   "X"
00208 
00209 #define SCNo16       "ho"
00210 #define SCNu16       "hu"
00211 #define SCNx16       "hx"
00212 #define SCNX16       "hX"
00213 #define SCNoLEAST16  "ho"
00214 #define SCNuLEAST16  "hu"
00215 #define SCNxLEAST16  "hx"
00216 #define SCNXLEAST16  "hX"
00217 #define SCNoFAST16   "ho"
00218 #define SCNuFAST16   "hu"
00219 #define SCNxFAST16   "hx"
00220 #define SCNXFAST16   "hX"
00221 
00222 #define SCNo32       "lo"
00223 #define SCNu32       "lu"
00224 #define SCNx32       "lx"
00225 #define SCNX32       "lX"
00226 #define SCNoLEAST32  "lo"
00227 #define SCNuLEAST32  "lu"
00228 #define SCNxLEAST32  "lx"
00229 #define SCNXLEAST32  "lX"
00230 #define SCNoFAST32   "lo"
00231 #define SCNuFAST32   "lu"
00232 #define SCNxFAST32   "lx"
00233 #define SCNXFAST32   "lX"
00234 
00235 #define SCNo64       "I64o"
00236 #define SCNu64       "I64u"
00237 #define SCNx64       "I64x"
00238 #define SCNX64       "I64X"
00239 #define SCNoLEAST64  "I64o"
00240 #define SCNuLEAST64  "I64u"
00241 #define SCNxLEAST64  "I64x"
00242 #define SCNXLEAST64  "I64X"
00243 #define SCNoFAST64   "I64o"
00244 #define SCNuFAST64   "I64u"
00245 #define SCNxFAST64   "I64x"
00246 #define SCNXFAST64   "I64X"
00247 
00248 #define SCNoMAX     "I64o"
00249 #define SCNuMAX     "I64u"
00250 #define SCNxMAX     "I64x"
00251 #define SCNXMAX     "I64X"
00252 
00253 #ifdef _WIN64 // [
00254 #  define SCNoPTR     "I64o"
00255 #  define SCNuPTR     "I64u"
00256 #  define SCNxPTR     "I64x"
00257 #  define SCNXPTR     "I64X"
00258 #else  // _WIN64 ][
00259 #  define SCNoPTR     "lo"
00260 #  define SCNuPTR     "lu"
00261 #  define SCNxPTR     "lx"
00262 #  define SCNXPTR     "lX"
00263 #endif  // _WIN64 ]
00264 
00265 #endif // __STDC_FORMAT_MACROS ]
00266 
00267 // 7.8.2 Functions for greatest-width integer types
00268 
00269 // 7.8.2.1 The imaxabs function
00270 #define imaxabs _abs64
00271 
00272 // 7.8.2.2 The imaxdiv function
00273 
00274 // This is modified version of div() function from Microsoft's div.c found
00275 // in %MSVC.NET%\crt\src\div.c
00276 #ifdef STATIC_IMAXDIV // [
00277 static
00278 #else // STATIC_IMAXDIV ][
00279 _inline
00280 #endif // STATIC_IMAXDIV ]
00281 imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
00282 {
00283    imaxdiv_t result;
00284 
00285    result.quot = numer / denom;
00286    result.rem = numer % denom;
00287 
00288    if (numer < 0 && result.rem > 0)
00289    {
00290       // did division wrong; must fix up
00291       ++result.quot;
00292       result.rem -= denom;
00293    }
00294 
00295    return result;
00296 }
00297 
00298 // 7.8.2.3 The strtoimax and strtoumax functions
00299 #define strtoimax _strtoi64
00300 #define strtoumax _strtoui64
00301 
00302 // 7.8.2.4 The wcstoimax and wcstoumax functions
00303 #define wcstoimax _wcstoi64
00304 #define wcstoumax _wcstoui64
00305 
00306 
00307 #endif // _MSC_INTTYPES_H_ ]


schunk_svh_driver
Author(s): Georg Heppner
autogenerated on Fri Aug 28 2015 12:59:19