Home | History | Annotate | Download | only in os-win32
      1 // ISO C9x  compliant inttypes.h for Microsoft Visual Studio
      2 // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
      3 //
      4 //  Copyright (c) 2006 Alexander Chemeris
      5 //
      6 // Redistribution and use in source and binary forms, with or without
      7 // modification, are permitted provided that the following conditions are met:
      8 //
      9 //   1. Redistributions of source code must retain the above copyright notice,
     10 //      this list of conditions and the following disclaimer.
     11 //
     12 //   2. Redistributions in binary form must reproduce the above copyright
     13 //      notice, this list of conditions and the following disclaimer in the
     14 //      documentation and/or other materials provided with the distribution.
     15 //
     16 //   3. The name of the author may be used to endorse or promote products
     17 //      derived from this software without specific prior written permission.
     18 //
     19 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
     20 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
     22 // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29 //
     30 ///////////////////////////////////////////////////////////////////////////////
     31 
     32 #ifndef INTTYPES_WIN32_H
     33 #define INTTYPES_WIN32_H
     34 
     35 #if !COMPILER(MSVC)
     36 #error "This inttypes.h file should only be compiled with MSVC"
     37 #endif
     38 
     39 #if _MSC_VER > 1000
     40 #pragma once
     41 #endif
     42 
     43 #include "stdint.h"
     44 
     45 // 7.8.1 Macros for format specifiers
     46 
     47 #if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)
     48 
     49 // The fprintf macros for signed integers are:
     50 #define PRId8       "d"
     51 #define PRIi8       "i"
     52 #define PRIdLEAST8  "d"
     53 #define PRIiLEAST8  "i"
     54 #define PRIdFAST8   "d"
     55 #define PRIiFAST8   "i"
     56 
     57 #define PRId16       "hd"
     58 #define PRIi16       "hi"
     59 #define PRIdLEAST16  "hd"
     60 #define PRIiLEAST16  "hi"
     61 #define PRIdFAST16   "hd"
     62 #define PRIiFAST16   "hi"
     63 
     64 #define PRId32       "d"
     65 #define PRIi32       "i"
     66 #define PRIdLEAST32  "d"
     67 #define PRIiLEAST32  "i"
     68 #define PRIdFAST32   "d"
     69 #define PRIiFAST32   "i"
     70 
     71 #define PRId64       "lld"
     72 #define PRIi64       "lli"
     73 #define PRIdLEAST64  "lld"
     74 #define PRIiLEAST64  "lli"
     75 #define PRIdFAST64   "lld"
     76 #define PRIiFAST64   "lli"
     77 
     78 #define PRIdMAX     "lld"
     79 #define PRIiMAX     "lli"
     80 
     81 #define PRIdPTR     "Id"
     82 #define PRIiPTR     "Ii"
     83 
     84 // The fprintf macros for unsigned integers are:
     85 #define PRIo8       "o"
     86 #define PRIu8       "u"
     87 #define PRIx8       "x"
     88 #define PRIX8       "X"
     89 #define PRIoLEAST8  "o"
     90 #define PRIuLEAST8  "u"
     91 #define PRIxLEAST8  "x"
     92 #define PRIXLEAST8  "X"
     93 #define PRIoFAST8   "o"
     94 #define PRIuFAST8   "u"
     95 #define PRIxFAST8   "x"
     96 #define PRIXFAST8   "X"
     97 
     98 #define PRIo16       "ho"
     99 #define PRIu16       "hu"
    100 #define PRIx16       "hx"
    101 #define PRIX16       "hX"
    102 #define PRIoLEAST16  "ho"
    103 #define PRIuLEAST16  "hu"
    104 #define PRIxLEAST16  "hx"
    105 #define PRIXLEAST16  "hX"
    106 #define PRIoFAST16   "ho"
    107 #define PRIuFAST16   "hu"
    108 #define PRIxFAST16   "hx"
    109 #define PRIXFAST16   "hX"
    110 
    111 #define PRIo32       "o"
    112 #define PRIu32       "u"
    113 #define PRIx32       "x"
    114 #define PRIX32       "X"
    115 #define PRIoLEAST32  "o"
    116 #define PRIuLEAST32  "u"
    117 #define PRIxLEAST32  "x"
    118 #define PRIXLEAST32  "X"
    119 #define PRIoFAST32   "o"
    120 #define PRIuFAST32   "u"
    121 #define PRIxFAST32   "x"
    122 #define PRIXFAST32   "X"
    123 
    124 #define PRIo64       "llo"
    125 #define PRIu64       "llu"
    126 #define PRIx64       "llx"
    127 #define PRIX64       "llX"
    128 #define PRIoLEAST64  "llo"
    129 #define PRIuLEAST64  "llu"
    130 #define PRIxLEAST64  "llx"
    131 #define PRIXLEAST64  "llX"
    132 #define PRIoFAST64   "llo"
    133 #define PRIuFAST64   "llu"
    134 #define PRIxFAST64   "llx"
    135 #define PRIXFAST64   "llX"
    136 
    137 #define PRIoMAX     "llo"
    138 #define PRIuMAX     "llu"
    139 #define PRIxMAX     "llx"
    140 #define PRIXMAX     "llX"
    141 
    142 #define PRIoPTR     "Io"
    143 #define PRIuPTR     "Iu"
    144 #define PRIxPTR     "Ix"
    145 #define PRIXPTR     "IX"
    146 
    147 // The fscanf macros for signed integers are:
    148 #define SCNd8       "d"
    149 #define SCNi8       "i"
    150 #define SCNdLEAST8  "d"
    151 #define SCNiLEAST8  "i"
    152 #define SCNdFAST8   "d"
    153 #define SCNiFAST8   "i"
    154 
    155 #define SCNd16       "hd"
    156 #define SCNi16       "hi"
    157 #define SCNdLEAST16  "hd"
    158 #define SCNiLEAST16  "hi"
    159 #define SCNdFAST16   "hd"
    160 #define SCNiFAST16   "hi"
    161 
    162 #define SCNd32       "ld"
    163 #define SCNi32       "li"
    164 #define SCNdLEAST32  "ld"
    165 #define SCNiLEAST32  "li"
    166 #define SCNdFAST32   "ld"
    167 #define SCNiFAST32   "li"
    168 
    169 #define SCNd64       "lld"
    170 #define SCNi64       "lli"
    171 #define SCNdLEAST64  "lld"
    172 #define SCNiLEAST64  "lli"
    173 #define SCNdFAST64   "lld"
    174 #define SCNiFAST64   "lli"
    175 
    176 #define SCNdMAX     "lld"
    177 #define SCNiMAX     "lli"
    178 
    179 #ifdef _WIN64
    180 #  define SCNdPTR     "lld"
    181 #  define SCNiPTR     "lli"
    182 #else
    183 #  define SCNdPTR     "ld"
    184 #  define SCNiPTR     "li"
    185 #endif
    186 
    187 // The fscanf macros for unsigned integers are:
    188 #define SCNo8       "o"
    189 #define SCNu8       "u"
    190 #define SCNx8       "x"
    191 #define SCNX8       "X"
    192 #define SCNoLEAST8  "o"
    193 #define SCNuLEAST8  "u"
    194 #define SCNxLEAST8  "x"
    195 #define SCNXLEAST8  "X"
    196 #define SCNoFAST8   "o"
    197 #define SCNuFAST8   "u"
    198 #define SCNxFAST8   "x"
    199 #define SCNXFAST8   "X"
    200 
    201 #define SCNo16       "ho"
    202 #define SCNu16       "hu"
    203 #define SCNx16       "hx"
    204 #define SCNX16       "hX"
    205 #define SCNoLEAST16  "ho"
    206 #define SCNuLEAST16  "hu"
    207 #define SCNxLEAST16  "hx"
    208 #define SCNXLEAST16  "hX"
    209 #define SCNoFAST16   "ho"
    210 #define SCNuFAST16   "hu"
    211 #define SCNxFAST16   "hx"
    212 #define SCNXFAST16   "hX"
    213 
    214 #define SCNo32       "lo"
    215 #define SCNu32       "lu"
    216 #define SCNx32       "lx"
    217 #define SCNX32       "lX"
    218 #define SCNoLEAST32  "lo"
    219 #define SCNuLEAST32  "lu"
    220 #define SCNxLEAST32  "lx"
    221 #define SCNXLEAST32  "lX"
    222 #define SCNoFAST32   "lo"
    223 #define SCNuFAST32   "lu"
    224 #define SCNxFAST32   "lx"
    225 #define SCNXFAST32   "lX"
    226 
    227 #define SCNo64       "llo"
    228 #define SCNu64       "llu"
    229 #define SCNx64       "llx"
    230 #define SCNX64       "llX"
    231 #define SCNoLEAST64  "llo"
    232 #define SCNuLEAST64  "llu"
    233 #define SCNxLEAST64  "llx"
    234 #define SCNXLEAST64  "llX"
    235 #define SCNoFAST64   "llo"
    236 #define SCNuFAST64   "llu"
    237 #define SCNxFAST64   "llx"
    238 #define SCNXFAST64   "llX"
    239 
    240 #define SCNoMAX     "llo"
    241 #define SCNuMAX     "llu"
    242 #define SCNxMAX     "llx"
    243 #define SCNXMAX     "llX"
    244 
    245 #ifdef _WIN64
    246 #  define SCNoPTR     "llo"
    247 #  define SCNuPTR     "llu"
    248 #  define SCNxPTR     "llx"
    249 #  define SCNXPTR     "llX"
    250 #else
    251 #  define SCNoPTR     "lo"
    252 #  define SCNuPTR     "lu"
    253 #  define SCNxPTR     "lx"
    254 #  define SCNXPTR     "lX"
    255 #endif
    256 
    257 #endif
    258 
    259 #endif
    260