Fix sizeof/offsetof assertions.

This commit is contained in:
Skyth 2024-11-25 18:29:15 +03:00
parent 49b0dbe4db
commit 349f07cf77
4 changed files with 5 additions and 18 deletions

View file

@ -12,6 +12,7 @@ add_compile_options(
-Wno-unused-but-set-variable
-Wno-void-pointer-to-int-cast
-Wno-int-to-void-pointer-cast
-Wno-invalid-offsetof
)
add_compile_definitions(

View file

@ -15,7 +15,6 @@
#include "CSD/Manager/csdmSceneObserver.h"
#include "CSD/Manager/csdmSubjectBase.h"
#include "CSD/Platform/csdTexList.h"
#include "Hedgehog/Base/Container/hhVector.h"
#include "Hedgehog/Base/System/hhAllocator.h"
#include "Hedgehog/Base/Thread/hhHolder.h"
#include "Hedgehog/Base/Thread/hhHolderBase.h"

View file

@ -11,26 +11,12 @@
uint8_t SWA_CONCAT(pad, __LINE__)[length]
#define SWA_ASSERT_OFFSETOF(type, field, offset) \
static inline swa_assert_offsetof<BB_OFFSETOF(type, field), offset> SWA_CONCAT(_, __COUNTER__)
static_assert(offsetof(type, field) == offset)
#define SWA_ASSERT_SIZEOF(type, size) \
static inline swa_assert_sizeof<sizeof type, size> SWA_CONCAT(_, __COUNTER__)
static_assert(sizeof(type) == size)
#define SWA_VIRTUAL_FUNCTION(returnType, virtualIndex, ...) \
GuestToHostFunction<returnType>(*(be<uint32_t>*)(g_memory.Translate(*(be<uint32_t>*)(this) + (4 * virtualIndex))), __VA_ARGS__)
struct swa_null_ctor
{
};
template<int TActual, int TExpected>
struct swa_assert_offsetof
{
static_assert(TActual == TExpected, "offsetof assertion failed");
};
template<int TActual, int TExpected>
struct swa_assert_sizeof
{
static_assert(TActual == TExpected, "sizeof assertion failed");
};
struct swa_null_ctor {};

View file

@ -27,6 +27,7 @@
#include <imgui_internal.h>
#include <imgui_impl_sdl2.h>
#include <o1heap.h>
#include <cstddef>
#include "framework.h"
#include "mutex.h"