2
0

int.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* This takes the place of C99 inttypes.h, which at least some Windows
  2. compilers don't have. (October 2007).
  3. */
  4. /* PRId64 is the printf-style format specifier for a long long type, as in
  5. long long mynumber = 5;
  6. printf("My number is %" PRId64 ".\n", mynumber);
  7. The LL/ULL macro is for 64 bit integer literals, like this:
  8. long long mask= ULL(1) << 33;
  9. */
  10. /* 'uint' is quite convenient, but there's no simple way have it everywhere.
  11. Some systems have it in the base system (e.g. GNU C library has it in
  12. <sys/types.h>, and others (e.g. Solaris - 08.12.02) don't. Since we
  13. can't define it unless we know it's not defined already, and we don't
  14. want to burden the reader with a special Xmlrpc-c name such as xuint,
  15. we just use standard "unsigned int" instead.
  16. */
  17. #ifdef _MSC_VER
  18. # define PRId64 "I64d"
  19. # define PRIu64 "I64u"
  20. #ifndef int16_t
  21. typedef short int16_t;
  22. #endif
  23. #ifndef uint16_t
  24. typedef unsigned short uint16_t;
  25. #endif
  26. #ifndef int32_t
  27. typedef int int32_t;
  28. #endif
  29. #ifndef uint32_t
  30. typedef unsigned int uint32_t;
  31. #endif
  32. #ifndef int64_t
  33. typedef __int64 int64_t;
  34. #endif
  35. #ifndef uint64_t
  36. typedef unsigned __int64 uint64_t;
  37. #endif
  38. #ifndef uint8_t
  39. typedef unsigned char uint8_t;
  40. #endif
  41. /* Older Microsoft compilers don't know the standard ll/ull suffixes */
  42. #define LL(x) x ## i64
  43. #define ULL(x) x ## u64
  44. #elif defined(__INTERIX)
  45. # include <stdint.h>
  46. # define PRId64 "I64d"
  47. # define PRIu64 "I64u"
  48. #else
  49. /* Not Microsoft compiler */
  50. #include <inttypes.h>
  51. #define LL(x) x ## ll
  52. #define ULL(x) x ## ull
  53. #endif