Home | History | Annotate | Download | only in include
      1 /**
      2  * This file has no copyright assigned and is placed in the Public Domain.
      3  * This file is part of the mingw-w64 runtime package.
      4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
      5  */
      6 /* 7.8 Format conversion of integer types <inttypes.h> */
      7 
      8 #ifndef _INTTYPES_H_
      9 #define _INTTYPES_H_
     10 
     11 #include <crtdefs.h>
     12 #include <stdint.h>
     13 #define __need_wchar_t
     14 #include <stddef.h>
     15 
     16 #ifdef	__cplusplus
     17 extern	"C"	{
     18 #endif
     19 
     20 typedef struct {
     21 	intmax_t quot;
     22 	intmax_t rem;
     23 	} imaxdiv_t;
     24 
     25 /* Restore to !define(__USE_MINGW_ANSI_STDIO) */
     26 #include <_mingw_print_push.h>
     27 
     28 #if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)
     29 
     30 /* 7.8.1 Macros for format specifiers
     31  *
     32  * MS runtime does not yet understand C9x standard "ll"
     33  * length specifier. It appears to treat "ll" as "l".
     34  * The non-standard I64 length specifier causes warning in GCC,
     35  * but understood by MS runtime functions.
     36  */
     37 
     38 /* fprintf macros for signed types */
     39 #define PRId8 "d"
     40 #define PRId16 "d"
     41 #define PRId32 "d"
     42 #define PRId64 "I64d"
     43 
     44 #define PRIdLEAST8 "d"
     45 #define PRIdLEAST16 "d"
     46 #define PRIdLEAST32 "d"
     47 #define PRIdLEAST64 "I64d"
     48 
     49 #define PRIdFAST8 "d"
     50 #define PRIdFAST16 "d"
     51 #define PRIdFAST32 "d"
     52 #define PRIdFAST64 "I64d"
     53 
     54 #define PRIdMAX "I64d"
     55 
     56 #define PRIi8 "i"
     57 #define PRIi16 "i"
     58 #define PRIi32 "i"
     59 #define PRIi64 "I64i"
     60 
     61 #define PRIiLEAST8 "i"
     62 #define PRIiLEAST16 "i"
     63 #define PRIiLEAST32 "i"
     64 #define PRIiLEAST64 "I64i"
     65 
     66 #define PRIiFAST8 "i"
     67 #define PRIiFAST16 "i"
     68 #define PRIiFAST32 "i"
     69 #define PRIiFAST64 "I64i"
     70 
     71 #define PRIiMAX "I64i"
     72 
     73 #define PRIo8 "o"
     74 #define PRIo16 "o"
     75 #define PRIo32 "o"
     76 #define PRIo64 "I64o"
     77 
     78 #define PRIoLEAST8 "o"
     79 #define PRIoLEAST16 "o"
     80 #define PRIoLEAST32 "o"
     81 #define PRIoLEAST64 "I64o"
     82 
     83 #define PRIoFAST8 "o"
     84 #define PRIoFAST16 "o"
     85 #define PRIoFAST32 "o"
     86 #define PRIoFAST64 "I64o"
     87 
     88 #define PRIoMAX "I64o"
     89 
     90 /* fprintf macros for unsigned types */
     91 #define PRIu8 "u"
     92 #define PRIu16 "u"
     93 #define PRIu32 "u"
     94 #define PRIu64 "I64u"
     95 
     96 
     97 #define PRIuLEAST8 "u"
     98 #define PRIuLEAST16 "u"
     99 #define PRIuLEAST32 "u"
    100 #define PRIuLEAST64 "I64u"
    101 
    102 #define PRIuFAST8 "u"
    103 #define PRIuFAST16 "u"
    104 #define PRIuFAST32 "u"
    105 #define PRIuFAST64 "I64u"
    106 
    107 #define PRIuMAX "I64u"
    108 
    109 #define PRIx8 "x"
    110 #define PRIx16 "x"
    111 #define PRIx32 "x"
    112 #define PRIx64 "I64x"
    113 
    114 #define PRIxLEAST8 "x"
    115 #define PRIxLEAST16 "x"
    116 #define PRIxLEAST32 "x"
    117 #define PRIxLEAST64 "I64x"
    118 
    119 #define PRIxFAST8 "x"
    120 #define PRIxFAST16 "x"
    121 #define PRIxFAST32 "x"
    122 #define PRIxFAST64 "I64x"
    123 
    124 #define PRIxMAX "I64x"
    125 
    126 #define PRIX8 "X"
    127 #define PRIX16 "X"
    128 #define PRIX32 "X"
    129 #define PRIX64 "I64X"
    130 
    131 #define PRIXLEAST8 "X"
    132 #define PRIXLEAST16 "X"
    133 #define PRIXLEAST32 "X"
    134 #define PRIXLEAST64 "I64X"
    135 
    136 #define PRIXFAST8 "X"
    137 #define PRIXFAST16 "X"
    138 #define PRIXFAST32 "X"
    139 #define PRIXFAST64 "I64X"
    140 
    141 #define PRIXMAX "I64X"
    142 
    143 /*
    144  *   fscanf macros for signed int types
    145  *   NOTE: if 32-bit int is used for int_fast8_t and int_fast16_t
    146  *   (see stdint.h, 7.18.1.3), FAST8 and FAST16 should have
    147  *   no length identifiers
    148  */
    149 
    150 #define SCNd16 "hd"
    151 #define SCNd32 "d"
    152 #define SCNd64 "I64d"
    153 
    154 #define SCNdLEAST16 "hd"
    155 #define SCNdLEAST32 "d"
    156 #define SCNdLEAST64 "I64d"
    157 
    158 #define SCNdFAST16 "hd"
    159 #define SCNdFAST32 "d"
    160 #define SCNdFAST64 "I64d"
    161 
    162 #define SCNdMAX "I64d"
    163 
    164 #define SCNi16 "hi"
    165 #define SCNi32 "i"
    166 #define SCNi64 "I64i"
    167 
    168 #define SCNiLEAST16 "hi"
    169 #define SCNiLEAST32 "i"
    170 #define SCNiLEAST64 "I64i"
    171 
    172 #define SCNiFAST16 "hi"
    173 #define SCNiFAST32 "i"
    174 #define SCNiFAST64 "I64i"
    175 
    176 #define SCNiMAX "I64i"
    177 
    178 #define SCNo16 "ho"
    179 #define SCNo32 "o"
    180 #define SCNo64 "I64o"
    181 
    182 #define SCNoLEAST16 "ho"
    183 #define SCNoLEAST32 "o"
    184 #define SCNoLEAST64 "I64o"
    185 
    186 #define SCNoFAST16 "ho"
    187 #define SCNoFAST32 "o"
    188 #define SCNoFAST64 "I64o"
    189 
    190 #define SCNoMAX "I64o"
    191 
    192 #define SCNx16 "hx"
    193 #define SCNx32 "x"
    194 #define SCNx64 "I64x"
    195 
    196 #define SCNxLEAST16 "hx"
    197 #define SCNxLEAST32 "x"
    198 #define SCNxLEAST64 "I64x"
    199 
    200 #define SCNxFAST16 "hx"
    201 #define SCNxFAST32 "x"
    202 #define SCNxFAST64 "I64x"
    203 
    204 #define SCNxMAX "I64x"
    205 
    206 /* fscanf macros for unsigned int types */
    207 
    208 #define SCNu16 "hu"
    209 #define SCNu32 "u"
    210 #define SCNu64 "I64u"
    211 
    212 #define SCNuLEAST16 "hu"
    213 #define SCNuLEAST32 "u"
    214 #define SCNuLEAST64 "I64u"
    215 
    216 #define SCNuFAST16 "hu"
    217 #define SCNuFAST32 "u"
    218 #define SCNuFAST64 "I64u"
    219 
    220 #define SCNuMAX "I64u"
    221 
    222 #ifdef _WIN64
    223 #define PRIdPTR "I64d"
    224 #define PRIiPTR "I64i"
    225 #define PRIoPTR "I64o"
    226 #define PRIuPTR "I64u"
    227 #define PRIxPTR "I64x"
    228 #define PRIXPTR "I64X"
    229 #define SCNdPTR "I64d"
    230 #define SCNiPTR "I64i"
    231 #define SCNoPTR "I64o"
    232 #define SCNxPTR "I64x"
    233 #define SCNuPTR "I64u"
    234 #else
    235 #define PRIdPTR "d"
    236 #define PRIiPTR "i"
    237 #define PRIoPTR "o"
    238 #define PRIuPTR "u"
    239 #define PRIxPTR "x"
    240 #define PRIXPTR "X"
    241 #define SCNdPTR "d"
    242 #define SCNiPTR "i"
    243 #define SCNoPTR "o"
    244 #define SCNxPTR "x"
    245  #define SCNuPTR "u"
    246 #endif
    247 
    248 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    249 /*
    250  * no length modifier for char types prior to C9x
    251  * MS runtime  scanf appears to treat "hh" as "h"
    252  */
    253 
    254 /* signed char */
    255 #define SCNd8 "hhd"
    256 #define SCNdLEAST8 "hhd"
    257 #define SCNdFAST8 "hhd"
    258 
    259 #define SCNi8 "hhi"
    260 #define SCNiLEAST8 "hhi"
    261 #define SCNiFAST8 "hhi"
    262 
    263 #define SCNo8 "hho"
    264 #define SCNoLEAST8 "hho"
    265 #define SCNoFAST8 "hho"
    266 
    267 #define SCNx8 "hhx"
    268 #define SCNxLEAST8 "hhx"
    269 #define SCNxFAST8 "hhx"
    270 
    271 /* unsigned char */
    272 #define SCNu8 "hhu"
    273 #define SCNuLEAST8 "hhu"
    274 #define SCNuFAST8 "hhu"
    275 #endif /* __STDC_VERSION__ >= 199901 */
    276 
    277 #endif	/* !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) */
    278 
    279 intmax_t __cdecl imaxabs (intmax_t j);
    280 #ifndef __CRT__NO_INLINE
    281 __CRT_INLINE intmax_t __cdecl imaxabs (intmax_t j)
    282 	{return	(j >= 0 ? j : -j);}
    283 #endif
    284 imaxdiv_t __cdecl imaxdiv (intmax_t numer, intmax_t denom);
    285 
    286 /* 7.8.2 Conversion functions for greatest-width integer types */
    287 
    288 intmax_t __cdecl strtoimax (const char* __restrict__ nptr,
    289                             char** __restrict__ endptr, int base);
    290 uintmax_t __cdecl strtoumax (const char* __restrict__ nptr,
    291 			     char** __restrict__ endptr, int base);
    292 
    293 intmax_t __cdecl wcstoimax (const wchar_t* __restrict__ nptr,
    294                             wchar_t** __restrict__ endptr, int base);
    295 uintmax_t __cdecl wcstoumax (const wchar_t* __restrict__ nptr,
    296 			     wchar_t** __restrict__ endptr, int base);
    297 
    298 /* Set PRI... and SCN... according to __USE_MINGW_ANSI_STDIO.  */
    299 #include <_mingw_print_pop.h>
    300 
    301 #ifdef	__cplusplus
    302 }
    303 #endif
    304 
    305 #endif /* ndef _INTTYPES_H */
    306