From 0d66571e86d86957899d11bea11b71183445663a Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Sat, 22 Jun 2024 09:54:20 -0400 Subject: [PATCH] Fix JUT_ASSERT to use double defines We know JUT_ASSERT originally had double defines because defines such as NULL and ARRAY_SIZE are expanded in assertion strings, as discovered by Jasper: https://godbolt.org/z/PvqsG9asb --- include/JSystem/JUtility/JUTAssert.h | 4 +++- include/m_Do/m_Do_main.h | 2 +- src/d/d_a_bomb_static.cpp | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/JSystem/JUtility/JUTAssert.h b/include/JSystem/JUtility/JUTAssert.h index f71c17f02..1f9d608d6 100644 --- a/include/JSystem/JUtility/JUTAssert.h +++ b/include/JSystem/JUtility/JUTAssert.h @@ -4,7 +4,9 @@ #include "dolphin/types.h" #include "dolphin/os/OS.h" -#define JUT_ASSERT(LINE, COND) (void)((COND) || (JUTAssertion::showAssert(JUTAssertion::getSDevice(), __FILE__, LINE, #COND), OSPanic(__FILE__, LINE, "Halt"), 0)); +#define JUT_SHOW_ASSERT(LINE, COND) JUTAssertion::showAssert(JUTAssertion::getSDevice(), __FILE__, LINE, #COND) + +#define JUT_ASSERT(LINE, COND) (void)((COND) || (JUT_SHOW_ASSERT(LINE, COND), OSPanic(__FILE__, LINE, "Halt"), 0)); // Favored by JAI (JAudio) #define JUT_ASSERT_MSG(LINE, COND, MSG) \ diff --git a/include/m_Do/m_Do_main.h b/include/m_Do/m_Do_main.h index cc448af22..1fa288c27 100644 --- a/include/m_Do/m_Do_main.h +++ b/include/m_Do/m_Do_main.h @@ -11,7 +11,7 @@ s32 LOAD_COPYDATE(void*); extern OSThread mainThread; -#define HeapCheckTableNum 6 +const int HeapCheckTableNum = 6; class HeapCheck { public: diff --git a/src/d/d_a_bomb_static.cpp b/src/d/d_a_bomb_static.cpp index 29826d9b6..ae4810fa9 100644 --- a/src/d/d_a_bomb_static.cpp +++ b/src/d/d_a_bomb_static.cpp @@ -7,7 +7,7 @@ #include "d/actor/d_a_bomb2.h" #include "JSystem/JUtility/JUTAssert.h" -#define L_daBomb_Version 1 +const int L_daBomb_Version = 1; /* 80067FA0-80067FD0 .text getBombRestTime__8daBomb_cFv */ s16 daBomb_c::getBombRestTime() {