diff options
| author | Mel <einebeere@gmail.com> | 2023-07-08 03:25:44 +0200 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2023-07-08 03:25:44 +0200 |
| commit | fe2baedc760c2f29e2c720f6b1132a2de33c5430 (patch) | |
| tree | dfbe1c72a17805a3cab6e0d47433e9021890c9ca /src/Common/Sizes.hpp | |
| parent | 41fbca10f6c6cdd9c1623f1347e7ecb40f5e7f59 (diff) | |
| download | meowcraft-fe2baedc760c2f29e2c720f6b1132a2de33c5430.tar.zst meowcraft-fe2baedc760c2f29e2c720f6b1132a2de33c5430.zip | |
Use own size types
Diffstat (limited to 'src/Common/Sizes.hpp')
| -rw-r--r-- | src/Common/Sizes.hpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/Common/Sizes.hpp b/src/Common/Sizes.hpp new file mode 100644 index 0000000..91422e5 --- /dev/null +++ b/src/Common/Sizes.hpp @@ -0,0 +1,46 @@ +#pragma once + +#include <cstdint> + +using I8 = int8_t; +using U8 = uint8_t; + +using I16 = int16_t; +using U16 = uint16_t; + +using I32 = int32_t; +using U32 = uint32_t; + +using I64 = int64_t; +using U64 = uint64_t; + +using ISize = I64; +using USize = U64; + +using F32 = float; +using F64 = double; + +using Bool = bool; + +using Char = char; + +using UInt = USize; +using Int = ISize; +using Real = F64; + +#define ASSERT_SIZE(type, bytes) \ + static_assert(sizeof(type) == (bytes), "Type '" #type "' should be exactly " #bytes " bytes.") + +ASSERT_SIZE(I8, 1); +ASSERT_SIZE(U8, 1); +ASSERT_SIZE(I16, 2); +ASSERT_SIZE(U16, 2); +ASSERT_SIZE(I32, 4); +ASSERT_SIZE(U32, 4); +ASSERT_SIZE(I64, 8); +ASSERT_SIZE(U64, 8); + +ASSERT_SIZE(F32, 4); +ASSERT_SIZE(F64, 8); + +ASSERT_SIZE(Bool, 1); \ No newline at end of file |
