10 #ifndef _PSTDINT_H_INCLUDED 20 defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && \ 21 __STDC_VERSION__ >= 199901L) || \ 22 (defined(__WATCOMC__) && __WATCOMC__ >= 1250) || \ 23 (defined(__GNUC__) && __GNUC__ > 2) || \ 24 (defined(_MSC_VER) && _MSC_VER >= 1600) || defined(IAR_ARM_CM3) || \ 25 (defined(__ICCARM__) && __ICCARM__) || \ 26 (defined(_ADI_COMPILER) && _ADI_COMPILER) || \ 27 (defined(__ICC8051__) && __ICC8051__) 32 defined(_STDINT_H_INCLUDED) || defined(_STDINT) || defined(_STDINT_H) || \ 33 defined(_STDINT_H_) || defined(BOOST_CSTDINT_HPP)) && \ 34 !defined(_PSTDINT_H_INCLUDED) 35 #define _PSTDINT_H_INCLUDED 36 #ifndef PRINTF_INT64_MODIFIER 37 #if (__WORDSIZE == 64) && !defined(__APPLE__) // lint !e553 __WORDSIZE should 40 #define PRINTF_INT64_MODIFIER "l" 42 #define PRINTF_INT64_MODIFIER "ll" 45 #ifndef PRINTF_INT32_MODIFIER 47 #define PRINTF_INT32_MODIFIER "" 49 #ifndef PRINTF_INT16_MODIFIER 50 #define PRINTF_INT16_MODIFIER "h" 52 #ifndef PRINTF_INTMAX_MODIFIER 53 #define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER 55 #ifndef PRINTF_INT64_HEX_WIDTH 56 #define PRINTF_INT64_HEX_WIDTH "16" 58 #ifndef PRINTF_INT32_HEX_WIDTH 59 #define PRINTF_INT32_HEX_WIDTH "8" 61 #ifndef PRINTF_INT16_HEX_WIDTH 62 #define PRINTF_INT16_HEX_WIDTH "4" 64 #ifndef PRINTF_INT8_HEX_WIDTH 65 #define PRINTF_INT8_HEX_WIDTH "2" 67 #ifndef PRINTF_INT64_DEC_WIDTH 68 #define PRINTF_INT64_DEC_WIDTH "20" 70 #ifndef PRINTF_INT32_DEC_WIDTH 71 #define PRINTF_INT32_DEC_WIDTH "10" 73 #ifndef PRINTF_INT16_DEC_WIDTH 74 #define PRINTF_INT16_DEC_WIDTH "5" 76 #ifndef PRINTF_INT8_DEC_WIDTH 77 #define PRINTF_INT8_DEC_WIDTH "3" 79 #ifndef PRINTF_INTMAX_HEX_WIDTH 80 #define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH 82 #ifndef PRINTF_INTMAX_DEC_WIDTH 83 #define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH 91 #if defined(__WATCOMC__) && __WATCOMC__ >= 1250 93 #define INT64_C(x) (x + (INT64_MAX - INT64_MAX)) 95 #if !defined(UINT64_C) 96 #define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX)) 99 #define INT32_C(x) (x + (INT32_MAX - INT32_MAX)) 101 #if !defined(UINT32_C) 102 #define UINT32_C(x) (x + (UINT32_MAX - UINT32_MAX)) 104 #if !defined(INT16_C) 105 #define INT16_C(x) (x) 107 #if !defined(UINT16_C) 108 #define UINT16_C(x) (x) 111 #define INT8_C(x) (x) 113 #if !defined(UINT8_C) 114 #define UINT8_C(x) (x) 116 #if !defined(UINT64_MAX) 117 #define UINT64_MAX 18446744073709551615ULL 119 #if !defined(INT64_MAX) 120 #define INT64_MAX 9223372036854775807LL 122 #if !defined(UINT32_MAX) 123 #define UINT32_MAX 4294967295UL 125 #if !defined(INT32_MAX) 126 #define INT32_MAX 2147483647L 128 #if !defined(INTMAX_MAX) 129 #define INTMAX_MAX INT64_MAX 131 #if !defined(INTMAX_MIN) 132 #define INTMAX_MIN INT64_MIN 140 #if (defined(_ADI_COMPILER) && _ADI_COMPILER) 142 typedef signed char int8_t;
153 #endif //(defined(_ADI_COMPILER) && _ADI_COMPILER) 157 #ifndef _PSTDINT_H_INCLUDED 158 #define _PSTDINT_H_INCLUDED 162 #define SIZE_MAX (~0) 164 #define SIZE_MAX (~(size_t)0) 175 #define UINT8_MAX 0xff 178 #if (UCHAR_MAX == UINT8_MAX) || defined(S_SPLINT_S) 180 #define UINT8_C(v) ((uint8_t)v) 182 #error "Platform not supported" 187 #define INT8_MAX 0x7f 190 #define INT8_MIN INT8_C(0x80) 193 #if (SCHAR_MAX == INT8_MAX) || defined(S_SPLINT_S) 194 typedef signed char int8_t;
195 #define INT8_C(v) ((int8_t)v) 197 #error "Platform not supported" 202 #define UINT16_MAX 0xffff 205 #if (UINT_MAX == UINT16_MAX) || defined(S_SPLINT_S) 207 #ifndef PRINTF_INT16_MODIFIER 208 #define PRINTF_INT16_MODIFIER "" 210 #define UINT16_C(v) ((uint16_t)(v)) 211 #elif (USHRT_MAX == UINT16_MAX) 213 #define UINT16_C(v) ((uint16_t)(v)) 214 #ifndef PRINTF_INT16_MODIFIER 215 #define PRINTF_INT16_MODIFIER "h" 218 #error "Platform not supported" 223 #define INT16_MAX 0x7fff 226 #define INT16_MIN INT16_C(0x8000) 229 #if (INT_MAX == INT16_MAX) || defined(S_SPLINT_S) 231 #define INT16_C(v) ((int16_t)(v)) 232 #ifndef PRINTF_INT16_MODIFIER 233 #define PRINTF_INT16_MODIFIER "" 235 #elif (SHRT_MAX == INT16_MAX) 237 #define INT16_C(v) ((int16_t)(v)) 238 #ifndef PRINTF_INT16_MODIFIER 239 #define PRINTF_INT16_MODIFIER "h" 242 #error "Platform not supported" 247 #define UINT32_MAX (0xffffffffUL) 250 #if (SIZE_MAX == UINT32_MAX) && !defined(S_SPLINT_S) && !defined(_lint) 252 #ifndef PRINTF_INT32_MODIFIER 253 #define PRINTF_INT32_MODIFIER "" 255 #define UINT32_C(v) v##U 256 #elif (ULONG_MAX == UINT32_MAX) || defined(S_SPLINT_S) 258 #define UINT32_C(v) v##UL 259 #ifndef PRINTF_INT32_MODIFIER 260 #define PRINTF_INT32_MODIFIER "l" 262 #elif (USHRT_MAX == UINT32_MAX) 264 #define UINT32_C(v) ((unsigned short)(v)) 265 #ifndef PRINTF_INT32_MODIFIER 266 #define PRINTF_INT32_MODIFIER "" 269 #error "Platform not supported" 274 #define INT32_MAX (0x7fffffffL) 277 #define INT32_MIN INT32_C(0x80000000) 280 #if (SIZE_MAX / 2 == INT32_MAX) && defined(__GNUC__) && (__GNUC__ > 3) 283 #ifndef PRINTF_INT32_MODIFIER 284 #define PRINTF_INT32_MODIFIER "" 286 #elif (LONG_MAX == INT32_MAX) || defined(S_SPLINT_S) 288 #define INT32_C(v) v##L 289 #ifndef PRINTF_INT32_MODIFIER 290 #define PRINTF_INT32_MODIFIER "l" 292 #elif (SIZE_MAX / 2 == INT32_MAX) 295 #ifndef PRINTF_INT32_MODIFIER 296 #define PRINTF_INT32_MODIFIER "" 298 #elif (SHRT_MAX == INT32_MAX) 300 #define INT32_C(v) ((short)(v)) 301 #ifndef PRINTF_INT32_MODIFIER 302 #define PRINTF_INT32_MODIFIER "" 305 #error "Platform not supported" 316 #undef stdint_int64_defined 317 #if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined(S_SPLINT_S) 318 #if (__STDC__ && __STDC_VERSION >= 199901L) || defined(S_SPLINT_S) 319 #define stdint_int64_defined 321 typedef unsigned long long uint64_t;
322 #define UINT64_C(v) v##ULL 323 #define INT64_C(v) v##LL 324 #ifndef PRINTF_INT64_MODIFIER 325 #define PRINTF_INT64_MODIFIER "ll" 330 #if !defined(stdint_int64_defined) 331 #if defined(__GNUC__) && __WORDSIZE == 64 332 #define stdint_int64_defined 333 __extension__
typedef long int64_t;
334 __extension__
typedef unsigned long uint64_t;
335 #define UINT64_C(v) v##UL 336 #define INT64_C(v) v##L 337 #ifndef PRINTF_INT64_MODIFIER 338 #define PRINTF_INT64_MODIFIER "l" 340 #elif defined(__GNUC__) 341 #define stdint_int64_defined 342 __extension__
typedef long long int64_t;
343 __extension__
typedef unsigned long long uint64_t;
344 #define UINT64_C(v) v##ULL 345 #define INT64_C(v) v##LL 346 #ifndef PRINTF_INT64_MODIFIER 347 #define PRINTF_INT64_MODIFIER "ll" 349 #elif defined(__MWERKS__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) || \ 350 defined(__APPLE_CC__) || defined(_LONG_LONG) || defined(_CRAYC) || \ 352 #define stdint_int64_defined 354 typedef unsigned long long uint64_t;
355 #define UINT64_C(v) v##ULL 356 #define INT64_C(v) v##LL 357 #ifndef PRINTF_INT64_MODIFIER 358 #define PRINTF_INT64_MODIFIER "ll" 360 #elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || \ 361 (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || \ 362 (defined(__BORLANDC__) && __BORLANDC__ > 0x460) || defined(__alpha) || \ 364 #define stdint_int64_defined 367 #define UINT64_C(v) v##UI64 368 #define INT64_C(v) v##I64 369 #ifndef PRINTF_INT64_MODIFIER 370 #define PRINTF_INT64_MODIFIER "I64" 375 #if !defined(LONG_LONG_MAX) && defined(INT64_C) 376 #define LONG_LONG_MAX INT64_C(9223372036854775807LL) 378 #ifndef ULONG_LONG_MAX 379 #define ULONG_LONG_MAX UINT64_C(18446744073709551615ULL) 382 #if !defined(INT64_MAX) && defined(INT64_C) 383 #define INT64_MAX INT64_C(9223372036854775807LL) 385 #if !defined(INT64_MIN) && defined(INT64_C) 387 #define INT64_MIN INT64_C(-9223372036854775808LL) 389 #if !defined(UINT64_MAX) && defined(INT64_C) 390 #define UINT64_MAX UINT64_C(18446744073709551615ULL) 397 #ifndef PRINTF_INT64_HEX_WIDTH 398 #define PRINTF_INT64_HEX_WIDTH "16" 400 #ifndef PRINTF_INT32_HEX_WIDTH 401 #define PRINTF_INT32_HEX_WIDTH "8" 403 #ifndef PRINTF_INT16_HEX_WIDTH 404 #define PRINTF_INT16_HEX_WIDTH "4" 406 #ifndef PRINTF_INT8_HEX_WIDTH 407 #define PRINTF_INT8_HEX_WIDTH "2" 410 #ifndef PRINTF_INT64_DEC_WIDTH 411 #define PRINTF_INT64_DEC_WIDTH "20" 413 #ifndef PRINTF_INT32_DEC_WIDTH 414 #define PRINTF_INT32_DEC_WIDTH "10" 416 #ifndef PRINTF_INT16_DEC_WIDTH 417 #define PRINTF_INT16_DEC_WIDTH "5" 419 #ifndef PRINTF_INT8_DEC_WIDTH 420 #define PRINTF_INT8_DEC_WIDTH "3" 429 #ifdef stdint_int64_defined 432 #define INTMAX_MAX INT64_MAX 433 #define INTMAX_MIN INT64_MIN 434 #define UINTMAX_MAX UINT64_MAX 435 #define UINTMAX_C(v) UINT64_C(v) 436 #define INTMAX_C(v) INT64_C(v) 437 #ifndef PRINTF_INTMAX_MODIFIER 438 #define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER 440 #ifndef PRINTF_INTMAX_HEX_WIDTH 441 #define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH 443 #ifndef PRINTF_INTMAX_DEC_WIDTH 444 #define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH 449 #define INTMAX_MAX INT32_MAX 450 #define UINTMAX_MAX UINT32_MAX 451 #define UINTMAX_C(v) UINT32_C(v) 452 #define INTMAX_C(v) INT32_C(v) 453 #ifndef PRINTF_INTMAX_MODIFIER 454 #define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER 456 #ifndef PRINTF_INTMAX_HEX_WIDTH 457 #define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH 459 #ifndef PRINTF_INTMAX_DEC_WIDTH 460 #define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH 471 #ifndef stdint_least_defined 478 #define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER 479 #define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER 480 #define UINT_LEAST8_MAX UINT8_MAX 481 #define INT_LEAST8_MAX INT8_MAX 482 #define UINT_LEAST16_MAX UINT16_MAX 483 #define INT_LEAST16_MAX INT16_MAX 484 #define UINT_LEAST32_MAX UINT32_MAX 485 #define INT_LEAST32_MAX INT32_MAX 486 #define INT_LEAST8_MIN INT8_MIN 487 #define INT_LEAST16_MIN INT16_MIN 488 #define INT_LEAST32_MIN INT32_MIN 489 #ifdef stdint_int64_defined 492 #define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER 493 #define UINT_LEAST64_MAX UINT64_MAX 494 #define INT_LEAST64_MAX INT64_MAX 495 #define INT_LEAST64_MIN INT64_MIN 498 #undef stdint_least_defined 520 #ifndef uint_fast16_t 526 #ifndef uint_fast32_t 529 #define UINT_FAST8_MAX UINT_LEAST8_MAX 530 #define INT_FAST8_MAX INT_LEAST8_MAX 531 #define UINT_FAST16_MAX UINT_LEAST16_MAX 532 #define INT_FAST16_MAX INT_LEAST16_MAX 533 #define UINT_FAST32_MAX UINT_LEAST32_MAX 534 #define INT_FAST32_MAX INT_LEAST32_MAX 535 #define INT_FAST8_MIN INT_LEAST8_MIN 536 #define INT_FAST16_MIN INT_LEAST16_MIN 537 #define INT_FAST32_MIN INT_LEAST32_MIN 538 #ifdef stdint_int64_defined 539 typedef int_least64_t int_fast64_t;
540 typedef uint_least64_t uint_fast64_t;
541 #define UINT_FAST64_MAX UINT_LEAST64_MAX 542 #define INT_FAST64_MAX INT_LEAST64_MAX 543 #define INT_FAST64_MIN INT_LEAST64_MIN 551 #if defined(__WATCOMC__) || defined(_MSC_VER) || defined(__GNUC__) 557 #define WCHAR_MAX ((wchar_t)-1) 566 #if defined(_MSC_VER) && defined(_UINTPTR_T_DEFINED) 567 #define STDINT_H_UINTPTR_T_DEFINED 570 #ifndef STDINT_H_UINTPTR_T_DEFINED 571 #if defined(__alpha__) || defined(__ia64__) || defined(__x86_64__) || \ 573 #define stdint_intptr_bits 64 574 #elif defined(__WATCOMC__) || defined(__TURBOC__) 575 #if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__) 576 #define stdint_intptr_bits 16 578 #define stdint_intptr_bits 32 580 #elif defined(__i386__) || defined(_WIN32) || defined(WIN32) 581 #define stdint_intptr_bits 32 582 #elif defined(__INTEL_COMPILER) 586 #ifdef stdint_intptr_bits 587 #define stdint_intptr_glue3_i(a, b, c) a##b##c 588 #define stdint_intptr_glue3(a, b, c) stdint_intptr_glue3_i(a, b, c) 589 #ifndef PRINTF_INTPTR_MODIFIER 590 #define PRINTF_INTPTR_MODIFIER \ 591 stdint_intptr_glue3(PRINTF_INT, stdint_intptr_bits, _MODIFIER) 594 #define PTRDIFF_MAX stdint_intptr_glue3(INT, stdint_intptr_bits, _MAX) 597 #define PTRDIFF_MIN stdint_intptr_glue3(INT, stdint_intptr_bits, _MIN) 600 #define UINTPTR_MAX stdint_intptr_glue3(UINT, stdint_intptr_bits, _MAX) 603 #define INTPTR_MAX stdint_intptr_glue3(INT, stdint_intptr_bits, _MAX) 606 #define INTPTR_MIN stdint_intptr_glue3(INT, stdint_intptr_bits, _MIN) 609 #define INTPTR_C(x) stdint_intptr_glue3(INT, stdint_intptr_bits, _C)(x) 612 #define UINTPTR_C(x) stdint_intptr_glue3(UINT, stdint_intptr_bits, _C)(x) 621 #define STDINT_H_UINTPTR_T_DEFINED 628 #ifndef SIG_ATOMIC_MAX 629 #define SIG_ATOMIC_MAX \ 630 ((((sig_atomic_t)1) << (sizeof(sig_atomic_t) * CHAR_BIT - 1)) - 1) 635 #if defined(__TEST_PSTDINT_FOR_CORRECTNESS) 646 #define glue3_aux(x, y, z) x##y##z 647 #define glue3(x, y, z) glue3_aux(x, y, z) 649 #define DECLU(bits) \ 650 glue3(uint, bits, _t) glue3(u, bits, =) glue3(UINT, bits, _C)(0); 651 #define DECLI(bits) \ 652 glue3(int, bits, _t) glue3(i, bits, =) glue3(INT, bits, _C)(0); 654 #define DECL(us, bits) glue3(DECL, us, )(bits) 656 #define TESTUMAX(bits) \ 657 glue3(u, bits, =) glue3(~, u, bits); \ 658 if (glue3(UINT, bits, _MAX) glue3(!=, u, bits)) \ 659 printf("Something wrong with UINT%d_MAX\n", bits) 675 char str0[256], str1[256];
677 sprintf(str0,
"%d %x\n", 0, ~0);
679 sprintf(str1,
"%d %x\n", i8, ~0);
680 if (0 != strcmp(str0, str1)) printf(
"Something wrong with i8 : %s\n", str1);
681 sprintf(str1,
"%u %x\n", u8, ~0);
682 if (0 != strcmp(str0, str1)) printf(
"Something wrong with u8 : %s\n", str1);
683 sprintf(str1,
"%d %x\n", i16, ~0);
684 if (0 != strcmp(str0, str1))
685 printf(
"Something wrong with i16 : %s\n", str1);
686 sprintf(str1,
"%u %x\n", u16, ~0);
687 if (0 != strcmp(str0, str1))
688 printf(
"Something wrong with u16 : %s\n", str1);
690 if (0 != strcmp(str0, str1))
691 printf(
"Something wrong with i32 : %s\n", str1);
693 if (0 != strcmp(str0, str1))
694 printf(
"Something wrong with u32 : %s\n", str1);
696 sprintf(str1,
"%" PRINTF_INT64_MODIFIER
"d %x\n", i64, ~0);
697 if (0 != strcmp(str0, str1))
698 printf(
"Something wrong with i64 : %s\n", str1);
701 if (0 != strcmp(str0, str1))
702 printf(
"Something wrong with imax : %s\n", str1);
704 if (0 != strcmp(str0, str1))
705 printf(
"Something wrong with umax : %s\n", str1);
719 #if defined(_STDINT) && defined(_MSC_VER) 720 #define stdint_int64_defined
unsigned __int16 uint16_t
#define PRINTF_INT32_MODIFIER
int_least16_t int_fast16_t
unsigned __int64 uint64_t
#define stdint_intptr_bits
#define PRINTF_INTMAX_MODIFIER
#define stdint_intptr_glue3(a, b, c)
unsigned __int32 uint32_t
uint_least8_t uint_fast8_t
int_least32_t int_fast32_t
uint_least16_t uint_fast16_t
uint_least32_t uint_fast32_t
int sprintf(char *buf, size_t bufSize, const char *format,...) noexcept MRPT_printf_format_check(3
An OS-independent version of sprintf (Notice the bufSize param, which may be ignored in some compiler...