From e9b3df4d61da2e15966f1b5c4a9528d89caa43c6 Mon Sep 17 00:00:00 2001 From: PJB3005 Date: Tue, 24 Feb 2026 15:23:52 +0100 Subject: [PATCH] Fix primitive int types on 64-bit non-Windows targets `long` is variable-sized on non-Windows targets, so don't use it. Added some static_asserts to confirm this is the case. --- files.cmake | 1 + include/dolphin/types.h | 5 +++++ src/dusk/asserts.cpp | 11 +++++++++++ 3 files changed, 17 insertions(+) create mode 100644 src/dusk/asserts.cpp diff --git a/files.cmake b/files.cmake index f00741e0a0..b7cf5802da 100644 --- a/files.cmake +++ b/files.cmake @@ -1314,6 +1314,7 @@ set(REL_FILES ) set(DUSK_FILES + src/dusk/asserts.cpp src/dusk/imgui.cpp src/dusk/stubs.cpp src/dusk/extras.c diff --git a/include/dolphin/types.h b/include/dolphin/types.h index b957324094..17d63b4a76 100644 --- a/include/dolphin/types.h +++ b/include/dolphin/types.h @@ -8,8 +8,13 @@ typedef signed char s8; typedef unsigned char u8; typedef signed short int s16; typedef unsigned short int u16; +#if TARGET_PC +typedef signed int s32; +typedef unsigned int u32; +#else typedef signed long s32; typedef unsigned long u32; +#endif typedef signed long long int s64; typedef unsigned long long int u64; diff --git a/src/dusk/asserts.cpp b/src/dusk/asserts.cpp new file mode 100644 index 0000000000..8843970f3a --- /dev/null +++ b/src/dusk/asserts.cpp @@ -0,0 +1,11 @@ +#include +#include + +static_assert(sizeof(u8) == sizeof(uint8_t)); +static_assert(sizeof(s8) == sizeof(int8_t)); +static_assert(sizeof(u16) == sizeof(uint16_t)); +static_assert(sizeof(s16) == sizeof(int16_t)); +static_assert(sizeof(u32) == sizeof(uint32_t)); +static_assert(sizeof(s32) == sizeof(int32_t)); +static_assert(sizeof(u64) == sizeof(uint64_t)); +static_assert(sizeof(s64) == sizeof(int64_t));