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


fzi_icl_core
Author(s):
autogenerated on Thu Jun 6 2019 20:22:24