PrimitiveTypes.cpp 711 B

1234567891011121314151617181920212223
  1. // Copyright (c) 2008-2022 the Urho3D project
  2. // License: MIT
  3. #include <cstddef> // std::ptrdiff_t
  4. #include <cstdint> // std::intptr_t
  5. #include <limits> // std::numeric_limits
  6. // https://en.cppreference.com/w/cpp/language/types
  7. static_assert(std::numeric_limits<unsigned char>::digits == 8);
  8. static_assert(sizeof(short) == 2);
  9. static_assert(sizeof(int) == 4);
  10. static_assert(sizeof(long long) == 8);
  11. static_assert(sizeof(char32_t) == 4);
  12. #ifdef _WIN32 // Windows
  13. static_assert(sizeof(long) == 4);
  14. #else // Unix
  15. static_assert(sizeof(long) == sizeof(void*)); // 4 or 8
  16. #endif
  17. // Pointer arithmetics
  18. static_assert(sizeof(void*) == sizeof(std::ptrdiff_t));
  19. static_assert(sizeof(void*) == sizeof(std::intptr_t));