From 9181d58ecdd5577ab04f48453f8f1c0a9f6a1a0a Mon Sep 17 00:00:00 2001 From: Roz K Date: Fri, 6 Jan 2023 17:02:24 +0100 Subject: [PATCH] Add template for packed ints and fix missing define. --- cpp/types.hpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/cpp/types.hpp b/cpp/types.hpp index e6d7433..5f7d138 100644 --- a/cpp/types.hpp +++ b/cpp/types.hpp @@ -43,6 +43,28 @@ typedef unsigned __int128 rk_ullong; typedef float rk_float; typedef void * rk_handle_t; -#define RK_INVALID_HANDLE nullptr +static_assert(sizeof(rk_char) == 1); +static_assert(sizeof(rk_wchar) == 4); +static_assert(sizeof(rk_float) == 4); + +#pragma pack(push, 4) + +template +struct rk_packed { +}; + +template +struct alignas(alignof(rk_int)) rk_packed { + typedef rk_int type; + rk_int packed; +}; + +template +struct alignas(alignof(rk_uint)) rk_packed { + typedef rk_uint type; + rk_uint packed; +}; + +#pragma pack(pop) #endif // _RK_ENGINE_TYPES_H