prisize_t.h 852 B

12345678910111213141516171819202122232425262728
  1. /// @file
  2. /// @ingroup cgraph_utils
  3. #pragma once
  4. /// \brief \p PRIu64 alike for printing \p size_t
  5. ///
  6. /// Use this as:
  7. ///
  8. /// \code{.c}
  9. /// size_t value = 42;
  10. /// printf("value is %" PRISIZE_T ".", value);
  11. /// // prints “value is 42.”
  12. /// \endcode
  13. ///
  14. /// Note that leaving a space on either side of \p PRISIZE_T does not seem
  15. /// relevant in C, but if you omit this in C++ it will be interpreted as a
  16. /// user-defined string literal indicator. So it is best to always use a space
  17. /// on either side.
  18. #ifdef __MINGW64__
  19. // Microsoft’s Visual C Runtime (msvcrt) ships a printf that does not
  20. // understand "%zu". MSVC itself uses a different printf that does not rely on
  21. // this, but MinGW uses msvcrt and so cannot handle "%zu".
  22. #define PRISIZE_T "llu"
  23. #elif defined(__MINGW32__)
  24. #define PRISIZE_T "u"
  25. #else
  26. #define PRISIZE_T "zu"
  27. #endif