From 96ffd91c9a2cd145c0a40fb05de47af695fa6ffb Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Mon, 23 Feb 2026 20:17:37 +0100 Subject: [PATCH] Fix JASGlobalInstance instance definitions (#3108) There are a few places where JASGlobalInstance have their sInstance storage implemented via template specialization. The problem is that these have no initializer, which means that they are not proper definitions (only declarations) in standards-compliant C++. MSVC and (evidently) MWCC accept this, but modern Clang and GCC do not and won't emit symbols. I've added a macro that properly initializes these outside MWCC. Also, JASGlobalInstance was only being declared in each actor file that used it, which sounds incorrect? Not sure about this but I added it to m_Do_main too, again behind MWERKS check. --- include/JSystem/JAudio2/JASGadget.h | 6 ++++ src/Z2AudioCS/SpkSystem.cpp | 4 +-- src/m_Do/m_Do_main.cpp | 51 ++++++++++++++++------------- 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/include/JSystem/JAudio2/JASGadget.h b/include/JSystem/JAudio2/JASGadget.h index 718ce02069..53eaefb6a4 100644 --- a/include/JSystem/JAudio2/JASGadget.h +++ b/include/JSystem/JAudio2/JASGadget.h @@ -4,6 +4,12 @@ #include "JSystem/JUtility/JUTAssert.h" #include +#ifdef __MWERKS__ +#define JAS_GLOBAL_INSTANCE_INIT +#else +#define JAS_GLOBAL_INSTANCE_INIT {} +#endif + /** * @ingroup jsystem-jaudio * diff --git a/src/Z2AudioCS/SpkSystem.cpp b/src/Z2AudioCS/SpkSystem.cpp index 9e245f7503..ebb4c71ff6 100644 --- a/src/Z2AudioCS/SpkSystem.cpp +++ b/src/Z2AudioCS/SpkSystem.cpp @@ -7,8 +7,8 @@ #include "JSystem/JAudio2/JASHeapCtrl.h" #include "JSystem/JKernel/JKRHeap.h" -template<> SpkSystem* JASGlobalInstance::sInstance; -template<> SpkSoundHolder* JASGlobalInstance::sInstance; +template<> SpkSystem* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; +template<> SpkSoundHolder* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; const static s32 cConfigVolumeMax = 15; diff --git a/src/m_Do/m_Do_main.cpp b/src/m_Do/m_Do_main.cpp index 632c374ef1..901b8c980b 100644 --- a/src/m_Do/m_Do_main.cpp +++ b/src/m_Do/m_Do_main.cpp @@ -939,70 +939,75 @@ bool JKRHeap::dump_sort() { } template<> -Z2WolfHowlMgr* JASGlobalInstance::sInstance; +Z2WolfHowlMgr* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; template<> -Z2EnvSeMgr* JASGlobalInstance::sInstance; +Z2EnvSeMgr* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; template<> -Z2FxLineMgr* JASGlobalInstance::sInstance; +Z2FxLineMgr* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; template<> -Z2Audience* JASGlobalInstance::sInstance; +Z2Audience* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; template<> -Z2SoundObjMgr* JASGlobalInstance::sInstance; +Z2SoundObjMgr* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; template<> -Z2SoundInfo* JASGlobalInstance::sInstance; +Z2SoundInfo* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; template<> -JAUSoundInfo* JASGlobalInstance::sInstance; +JAUSoundInfo* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; template<> -JAUSoundNameTable* JASGlobalInstance::sInstance; +JAUSoundNameTable* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; template<> -JAUSoundTable* JASGlobalInstance::sInstance; +JAUSoundTable* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; template<> -JAISoundInfo* JASGlobalInstance::sInstance; +JAISoundInfo* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; template<> -Z2SoundMgr* JASGlobalInstance::sInstance; +Z2SoundMgr* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; template<> -JAIStreamMgr* JASGlobalInstance::sInstance; +JAIStreamMgr* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; template<> -JAISeqMgr* JASGlobalInstance::sInstance; +JAISeqMgr* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; template<> -JAISeMgr* JASGlobalInstance::sInstance; +JAISeMgr* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; template<> -Z2SpeechMgr2* JASGlobalInstance::sInstance; +Z2SpeechMgr2* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; template<> -Z2SoundStarter* JASGlobalInstance::sInstance; +Z2SoundStarter* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; template<> -JAISoundStarter* JASGlobalInstance::sInstance; +JAISoundStarter* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; template<> -Z2StatusMgr* JASGlobalInstance::sInstance; +Z2StatusMgr* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; template<> -Z2SceneMgr* JASGlobalInstance::sInstance; +Z2SceneMgr* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; template<> -Z2SeqMgr* JASGlobalInstance::sInstance; +Z2SeqMgr* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; template<> -Z2SeMgr* JASGlobalInstance::sInstance; +Z2SeMgr* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; template<> -JASAudioThread* JASGlobalInstance::sInstance; +JASAudioThread* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; template<> -JASDefaultBankTable* JASGlobalInstance::sInstance; +JASDefaultBankTable* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; + +#ifndef __MWERKS__ +template<> +JAUSectionHeap* JASGlobalInstance::sInstance JAS_GLOBAL_INSTANCE_INIT; +#endif