Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/inttypes.h
1 /* Copyright (C) 1997-2026 Free Software Foundation, Inc. 2 This file is part of the GNU C Library. 3 4 The GNU C Library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 2.1 of the License, or (at your option) any later version. 8 9 The GNU C Library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 14 You should have received a copy of the GNU Lesser General Public 15 License along with the GNU C Library; if not, see 16 <https://www.gnu.org/licenses/>. */ 17 18 /* 19 * ISO C99: 7.8 Format conversion of integer types <inttypes.h> 20 */ 21 22 #ifndef _INTTYPES_H 23 #define _INTTYPES_H 1 24 25 #include <features.h> 26 27 #if __GLIBC_USE (ISOC23) 28 # define __STDC_VERSION_INTTYPES_H__ 202311L 29 #endif 30 31 /* Get the type definitions. */ 32 #include <stdint.h> 33 34 /* Get a definition for wchar_t. But we must not define wchar_t itself. */ 35 #ifndef ____gwchar_t_defined 36 # ifdef __cplusplus 37 # define __gwchar_t wchar_t 38 # elif defined __WCHAR_TYPE__ 39 typedef __WCHAR_TYPE__ __gwchar_t; 40 # else 41 # define __need_wchar_t 42 # include <stddef.h> 43 typedef wchar_t __gwchar_t; 44 # endif 45 # define ____gwchar_t_defined 1 46 #endif 47 48 # if __WORDSIZE == 64 49 # define __PRI64_PREFIX "l" 50 # define __PRIPTR_PREFIX "l" 51 # else 52 # define __PRI64_PREFIX "ll" 53 # define __PRIPTR_PREFIX 54 # endif 55 56 /* Macros for printing format specifiers. */ 57 58 /* Decimal notation. */ 59 # define PRId8 "hhd" 60 # define PRId16 "hd" 61 # define PRId32 "d" 62 # define PRId64 __PRI64_PREFIX "d" 63 64 # define PRIdLEAST8 "hhd" 65 # define PRIdLEAST16 "hd" 66 # define PRIdLEAST32 "d" 67 # define PRIdLEAST64 __PRI64_PREFIX "d" 68 69 # define PRIdFAST8 "hhd" 70 # define PRIdFAST16 __PRIPTR_PREFIX "d" 71 # define PRIdFAST32 __PRIPTR_PREFIX "d" 72 # define PRIdFAST64 __PRI64_PREFIX "d" 73 74 75 # define PRIi8 "hhi" 76 # define PRIi16 "hi" 77 # define PRIi32 "i" 78 # define PRIi64 __PRI64_PREFIX "i" 79 80 # define PRIiLEAST8 "hhi" 81 # define PRIiLEAST16 "hi" 82 # define PRIiLEAST32 "i" 83 # define PRIiLEAST64 __PRI64_PREFIX "i" 84 85 # define PRIiFAST8 "hhi" 86 # define PRIiFAST16 __PRIPTR_PREFIX "i" 87 # define PRIiFAST32 __PRIPTR_PREFIX "i" 88 # define PRIiFAST64 __PRI64_PREFIX "i" 89 90 /* Octal notation. */ 91 # define PRIo8 "hho" 92 # define PRIo16 "ho" 93 # define PRIo32 "o" 94 # define PRIo64 __PRI64_PREFIX "o" 95 96 # define PRIoLEAST8 "hho" 97 # define PRIoLEAST16 "ho" 98 # define PRIoLEAST32 "o" 99 # define PRIoLEAST64 __PRI64_PREFIX "o" 100 101 # define PRIoFAST8 "hho" 102 # define PRIoFAST16 __PRIPTR_PREFIX "o" 103 # define PRIoFAST32 __PRIPTR_PREFIX "o" 104 # define PRIoFAST64 __PRI64_PREFIX "o" 105 106 /* Unsigned integers. */ 107 # define PRIu8 "hhu" 108 # define PRIu16 "hu" 109 # define PRIu32 "u" 110 # define PRIu64 __PRI64_PREFIX "u" 111 112 # define PRIuLEAST8 "hhu" 113 # define PRIuLEAST16 "hu" 114 # define PRIuLEAST32 "u" 115 # define PRIuLEAST64 __PRI64_PREFIX "u" 116 117 # define PRIuFAST8 "hhu" 118 # define PRIuFAST16 __PRIPTR_PREFIX "u" 119 # define PRIuFAST32 __PRIPTR_PREFIX "u" 120 # define PRIuFAST64 __PRI64_PREFIX "u" 121 122 /* lowercase hexadecimal notation. */ 123 # define PRIx8 "hhx" 124 # define PRIx16 "hx" 125 # define PRIx32 "x" 126 # define PRIx64 __PRI64_PREFIX "x" 127 128 # define PRIxLEAST8 "hhx" 129 # define PRIxLEAST16 "hx" 130 # define PRIxLEAST32 "x" 131 # define PRIxLEAST64 __PRI64_PREFIX "x" 132 133 # define PRIxFAST8 "hhx" 134 # define PRIxFAST16 __PRIPTR_PREFIX "x" 135 # define PRIxFAST32 __PRIPTR_PREFIX "x" 136 # define PRIxFAST64 __PRI64_PREFIX "x" 137 138 /* UPPERCASE hexadecimal notation. */ 139 # define PRIX8 "hhX" 140 # define PRIX16 "hX" 141 # define PRIX32 "X" 142 # define PRIX64 __PRI64_PREFIX "X" 143 144 # define PRIXLEAST8 "hhX" 145 # define PRIXLEAST16 "hX" 146 # define PRIXLEAST32 "X" 147 # define PRIXLEAST64 __PRI64_PREFIX "X" 148 149 # define PRIXFAST8 "hhX" 150 # define PRIXFAST16 __PRIPTR_PREFIX "X" 151 # define PRIXFAST32 __PRIPTR_PREFIX "X" 152 # define PRIXFAST64 __PRI64_PREFIX "X" 153 154 155 /* Macros for printing `intmax_t' and `uintmax_t'. */ 156 # define PRIdMAX __PRI64_PREFIX "d" 157 # define PRIiMAX __PRI64_PREFIX "i" 158 # define PRIoMAX __PRI64_PREFIX "o" 159 # define PRIuMAX __PRI64_PREFIX "u" 160 # define PRIxMAX __PRI64_PREFIX "x" 161 # define PRIXMAX __PRI64_PREFIX "X" 162 163 164 /* Macros for printing `intptr_t' and `uintptr_t'. */ 165 # define PRIdPTR __PRIPTR_PREFIX "d" 166 # define PRIiPTR __PRIPTR_PREFIX "i" 167 # define PRIoPTR __PRIPTR_PREFIX "o" 168 # define PRIuPTR __PRIPTR_PREFIX "u" 169 # define PRIxPTR __PRIPTR_PREFIX "x" 170 # define PRIXPTR __PRIPTR_PREFIX "X" 171 172 /* Binary notation. */ 173 # if __GLIBC_USE (ISOC23) 174 # define PRIb8 "hhb" 175 # define PRIb16 "hb" 176 # define PRIb32 "b" 177 # define PRIb64 __PRI64_PREFIX "b" 178 179 # define PRIbLEAST8 "hhb" 180 # define PRIbLEAST16 "hb" 181 # define PRIbLEAST32 "b" 182 # define PRIbLEAST64 __PRI64_PREFIX "b" 183 184 # define PRIbFAST8 "hhb" 185 # define PRIbFAST16 __PRIPTR_PREFIX "b" 186 # define PRIbFAST32 __PRIPTR_PREFIX "b" 187 # define PRIbFAST64 __PRI64_PREFIX "b" 188 189 # define PRIbMAX __PRI64_PREFIX "b" 190 # define PRIbPTR __PRIPTR_PREFIX "b" 191 192 # define PRIB8 "hhB" 193 # define PRIB16 "hB" 194 # define PRIB32 "B" 195 # define PRIB64 __PRI64_PREFIX "B" 196 197 # define PRIBLEAST8 "hhB" 198 # define PRIBLEAST16 "hB" 199 # define PRIBLEAST32 "B" 200 # define PRIBLEAST64 __PRI64_PREFIX "B" 201 202 # define PRIBFAST8 "hhB" 203 # define PRIBFAST16 __PRIPTR_PREFIX "B" 204 # define PRIBFAST32 __PRIPTR_PREFIX "B" 205 # define PRIBFAST64 __PRI64_PREFIX "B" 206 207 # define PRIBMAX __PRI64_PREFIX "B" 208 # define PRIBPTR __PRIPTR_PREFIX "B" 209 # endif 210 211 212 /* Macros for scanning format specifiers. */ 213 214 /* Signed decimal notation. */ 215 # define SCNd8 "hhd" 216 # define SCNd16 "hd" 217 # define SCNd32 "d" 218 # define SCNd64 __PRI64_PREFIX "d" 219 220 # define SCNdLEAST8 "hhd" 221 # define SCNdLEAST16 "hd" 222 # define SCNdLEAST32 "d" 223 # define SCNdLEAST64 __PRI64_PREFIX "d" 224 225 # define SCNdFAST8 "hhd" 226 # define SCNdFAST16 __PRIPTR_PREFIX "d" 227 # define SCNdFAST32 __PRIPTR_PREFIX "d" 228 # define SCNdFAST64 __PRI64_PREFIX "d" 229 230 /* Signed decimal notation. */ 231 # define SCNi8 "hhi" 232 # define SCNi16 "hi" 233 # define SCNi32 "i" 234 # define SCNi64 __PRI64_PREFIX "i" 235 236 # define SCNiLEAST8 "hhi" 237 # define SCNiLEAST16 "hi" 238 # define SCNiLEAST32 "i" 239 # define SCNiLEAST64 __PRI64_PREFIX "i" 240 241 # define SCNiFAST8 "hhi" 242 # define SCNiFAST16 __PRIPTR_PREFIX "i" 243 # define SCNiFAST32 __PRIPTR_PREFIX "i" 244 # define SCNiFAST64 __PRI64_PREFIX "i" 245 246 /* Unsigned decimal notation. */ 247 # define SCNu8 "hhu" 248 # define SCNu16 "hu" 249 # define SCNu32 "u" 250 # define SCNu64 __PRI64_PREFIX "u" 251 252 # define SCNuLEAST8 "hhu" 253 # define SCNuLEAST16 "hu" 254 # define SCNuLEAST32 "u" 255 # define SCNuLEAST64 __PRI64_PREFIX "u" 256 257 # define SCNuFAST8 "hhu" 258 # define SCNuFAST16 __PRIPTR_PREFIX "u" 259 # define SCNuFAST32 __PRIPTR_PREFIX "u" 260 # define SCNuFAST64 __PRI64_PREFIX "u" 261 262 /* Octal notation. */ 263 # define SCNo8 "hho" 264 # define SCNo16 "ho" 265 # define SCNo32 "o" 266 # define SCNo64 __PRI64_PREFIX "o" 267 268 # define SCNoLEAST8 "hho" 269 # define SCNoLEAST16 "ho" 270 # define SCNoLEAST32 "o" 271 # define SCNoLEAST64 __PRI64_PREFIX "o" 272 273 # define SCNoFAST8 "hho" 274 # define SCNoFAST16 __PRIPTR_PREFIX "o" 275 # define SCNoFAST32 __PRIPTR_PREFIX "o" 276 # define SCNoFAST64 __PRI64_PREFIX "o" 277 278 /* Hexadecimal notation. */ 279 # define SCNx8 "hhx" 280 # define SCNx16 "hx" 281 # define SCNx32 "x" 282 # define SCNx64 __PRI64_PREFIX "x" 283 284 # define SCNxLEAST8 "hhx" 285 # define SCNxLEAST16 "hx" 286 # define SCNxLEAST32 "x" 287 # define SCNxLEAST64 __PRI64_PREFIX "x" 288 289 # define SCNxFAST8 "hhx" 290 # define SCNxFAST16 __PRIPTR_PREFIX "x" 291 # define SCNxFAST32 __PRIPTR_PREFIX "x" 292 # define SCNxFAST64 __PRI64_PREFIX "x" 293 294 295 /* Macros for scanning `intmax_t' and `uintmax_t'. */ 296 # define SCNdMAX __PRI64_PREFIX "d" 297 # define SCNiMAX __PRI64_PREFIX "i" 298 # define SCNoMAX __PRI64_PREFIX "o" 299 # define SCNuMAX __PRI64_PREFIX "u" 300 # define SCNxMAX __PRI64_PREFIX "x" 301 302 /* Macros for scanning `intptr_t' and `uintptr_t'. */ 303 # define SCNdPTR __PRIPTR_PREFIX "d" 304 # define SCNiPTR __PRIPTR_PREFIX "i" 305 # define SCNoPTR __PRIPTR_PREFIX "o" 306 # define SCNuPTR __PRIPTR_PREFIX "u" 307 # define SCNxPTR __PRIPTR_PREFIX "x" 308 309 310 /* Binary notation. */ 311 # if __GLIBC_USE (ISOC23) 312 # define SCNb8 "hhb" 313 # define SCNb16 "hb" 314 # define SCNb32 "b" 315 # define SCNb64 __PRI64_PREFIX "b" 316 317 # define SCNbLEAST8 "hhb" 318 # define SCNbLEAST16 "hb" 319 # define SCNbLEAST32 "b" 320 # define SCNbLEAST64 __PRI64_PREFIX "b" 321 322 # define SCNbFAST8 "hhb" 323 # define SCNbFAST16 __PRIPTR_PREFIX "b" 324 # define SCNbFAST32 __PRIPTR_PREFIX "b" 325 # define SCNbFAST64 __PRI64_PREFIX "b" 326 327 # define SCNbMAX __PRI64_PREFIX "b" 328 # define SCNbPTR __PRIPTR_PREFIX "b" 329 # endif 330 331 332 __BEGIN_DECLS 333 334 #if __WORDSIZE == 64 335 336 /* We have to define the `uintmax_t' type using `ldiv_t'. */ 337 typedef struct 338 { 339 long int quot; /* Quotient. */ 340 long int rem; /* Remainder. */ 341 } imaxdiv_t; 342 343 #else 344 345 /* We have to define the `uintmax_t' type using `lldiv_t'. */ 346 typedef struct 347 { 348 __extension__ long long int quot; /* Quotient. */ 349 __extension__ long long int rem; /* Remainder. */ 350 } imaxdiv_t; 351 352 #endif 353 354 355 /* Compute absolute value of N. */ 356 extern intmax_t imaxabs (intmax_t __n) __THROW __attribute__ ((__const__)); 357 358 359 #if __GLIBC_USE (ISOC2Y) 360 extern uintmax_t umaxabs (intmax_t __n) __THROW __attribute__ ((__const__)); 361 #endif 362 363 /* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */ 364 extern imaxdiv_t imaxdiv (intmax_t __numer, intmax_t __denom) 365 __THROW __attribute__ ((__const__)); 366 367 /* Like `strtol' but convert to `intmax_t'. */ 368 extern intmax_t strtoimax (const char *__restrict __nptr, 369 char **__restrict __endptr, int __base) __THROW; 370 371 /* Like `strtoul' but convert to `uintmax_t'. */ 372 extern uintmax_t strtoumax (const char *__restrict __nptr, 373 char ** __restrict __endptr, int __base) __THROW; 374 375 /* Like `wcstol' but convert to `intmax_t'. */ 376 extern intmax_t wcstoimax (const __gwchar_t *__restrict __nptr, 377 __gwchar_t **__restrict __endptr, int __base) 378 __THROW; 379 380 /* Like `wcstoul' but convert to `uintmax_t'. */ 381 extern uintmax_t wcstoumax (const __gwchar_t *__restrict __nptr, 382 __gwchar_t ** __restrict __endptr, int __base) 383 __THROW; 384 385 /* Versions of the above functions that handle '0b' and '0B' prefixes 386 in base 0 or 2. */ 387 #if __GLIBC_USE (C23_STRTOL) 388 # ifdef __REDIRECT 389 extern intmax_t __REDIRECT_NTH (strtoimax, (const char *__restrict __nptr, 390 char **__restrict __endptr, 391 int __base), __isoc23_strtoimax); 392 extern uintmax_t __REDIRECT_NTH (strtoumax, (const char *__restrict __nptr, 393 char **__restrict __endptr, 394 int __base), __isoc23_strtoumax); 395 extern intmax_t __REDIRECT_NTH (wcstoimax, 396 (const __gwchar_t *__restrict __nptr, 397 __gwchar_t **__restrict __endptr, int __base), 398 __isoc23_wcstoimax); 399 extern uintmax_t __REDIRECT_NTH (wcstoumax, 400 (const __gwchar_t *__restrict __nptr, 401 __gwchar_t **__restrict __endptr, int __base), 402 __isoc23_wcstoumax); 403 # else 404 extern intmax_t __isoc23_strtoimax (const char *__restrict __nptr, 405 char **__restrict __endptr, int __base) 406 __THROW; 407 extern uintmax_t __isoc23_strtoumax (const char *__restrict __nptr, 408 char ** __restrict __endptr, int __base) 409 __THROW; 410 extern intmax_t __isoc23_wcstoimax (const __gwchar_t *__restrict __nptr, 411 __gwchar_t **__restrict __endptr, 412 int __base) 413 __THROW; 414 extern uintmax_t __isoc23_wcstoumax (const __gwchar_t *__restrict __nptr, 415 __gwchar_t ** __restrict __endptr, 416 int __base) 417 __THROW; 418 # define strtoimax __isoc23_strtoimax 419 # define strtoumax __isoc23_strtoumax 420 # define wcstoimax __isoc23_wcstoimax 421 # define wcstoumax __isoc23_wcstoumax 422 # endif 423 #endif 424 425 __END_DECLS 426 427 #endif /* inttypes.h */