inttypes.h 7.0 KB

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