Kumo
A hand-rolled game engine.
git clone https://git.sentomk.me/Kumo.git
types.h (1422B) · raw
1 /// @file core/types.h 2 /// @brief The integer types of the engine, usable without `std::`. 3 /// 4 /// The standard library promises `size_t` and the fixed-width integers such as 5 /// `uint32_t` in namespace std only. Whether the global names exist as well 6 /// depends on the implementation and on which other headers happen to be 7 /// included: libc++ (macOS) usually has them, libstdc++ (GNU) often does not, 8 /// so code that compiled on one failed on the other. 9 /// 10 /// This header settles it in one place. It includes the headers that declare 11 /// the types and brings the names into the global namespace. Every file of the 12 /// engine that uses them includes this header, and writes the plain names. 13 /// 14 /// A using-declaration is fine when the global name already exists: it names 15 /// the same type, and libstdc++ does the same in its own `<stddef.h>`. 16 #pragma once 17 18 #include <cstddef> 19 #include <cstdint> 20 21 using std::ptrdiff_t; 22 using std::size_t; 23 24 using std::int16_t; 25 using std::int32_t; 26 using std::int64_t; 27 using std::int8_t; 28 using std::intptr_t; 29 using std::uint16_t; 30 using std::uint32_t; 31 using std::uint64_t; 32 using std::uint8_t; 33 using std::uintptr_t; 34 35 // What the rest of the engine takes for granted. If a platform ever differs, 36 // the build stops here instead of computing something else. 37 static_assert(sizeof(int) == 4, "Kumo assumes a 32-bit int"); 38 static_assert(sizeof(void*) == 8, "Kumo assumes a 64-bit platform");
