summaryrefslogtreecommitdiff
path: root/include/JSystem
diff options
context:
space:
mode:
authorLuke Street <luke@street.dev>2026-02-28 21:19:17 -0700
committerGitHub <noreply@github.com>2026-02-28 20:19:17 -0800
commit6a48380461bc9baabe1706ba57ca0cedfa2d0c51 (patch)
tree593e054cfcb0250e63917c58b445a7e1f025a023 /include/JSystem
parentb5d3b8c059c10711370437f7db7539cd90f1cb29 (diff)
More GCC compatibility/warning fixes (#3118)
* Wrap >4-char literals in a MULTI_CHAR macro Modern compilers do not support CW's non-standard behavior with >4 char literals. We can, however, use a constexpr function to compute the u64 values directly. This leaves <=4 char literals unchanged. * Replace non-pointer usages of NULL with 0 * Define NULL to nullptr on C++11 and above * Fix more -Wpointer-arith and -Woverflow warnings * Replace u32/s32 with uintptr_t/intptr_t where appropriate * JSUOutputStream: Overload all standard int types
Diffstat (limited to 'include/JSystem')
-rw-r--r--include/JSystem/J2DGraph/J2DAnimation.h2
-rw-r--r--include/JSystem/JAudio2/JAISeMgr.h4
-rw-r--r--include/JSystem/JAudio2/JAISound.h7
-rw-r--r--include/JSystem/JAudio2/JASDSPInterface.h2
-rw-r--r--include/JSystem/JAudio2/JASResArcLoader.h6
-rw-r--r--include/JSystem/JKernel/JKRHeap.h3
-rw-r--r--include/JSystem/JStudio/JStudio/fvb-data.h2
-rw-r--r--include/JSystem/JStudio/JStudio/stb.h3
-rw-r--r--include/JSystem/JSupport/JSUOutputStream.h38
-rw-r--r--include/JSystem/JSupport/JSupport.h2
-rw-r--r--include/JSystem/JUtility/JUTXfb.h2
11 files changed, 34 insertions, 37 deletions
diff --git a/include/JSystem/J2DGraph/J2DAnimation.h b/include/JSystem/J2DGraph/J2DAnimation.h
index 035be59253..97183b8aae 100644
--- a/include/JSystem/J2DGraph/J2DAnimation.h
+++ b/include/JSystem/J2DGraph/J2DAnimation.h
@@ -59,7 +59,7 @@ public:
J2DAnmVtxColor() {
mKind = KIND_VTX_COLOR;
for (int i = 0; i < ARRAY_SIZE(mAnmTableNum); i++) {
- mAnmTableNum[i] = NULL;
+ mAnmTableNum[i] = 0;
}
for (int i = 0; i < ARRAY_SIZE(mVtxColorIndexData); i++) {
mVtxColorIndexData[i] = NULL;
diff --git a/include/JSystem/JAudio2/JAISeMgr.h b/include/JSystem/JAudio2/JAISeMgr.h
index 50f81fb1b4..928d85525b 100644
--- a/include/JSystem/JAudio2/JAISeMgr.h
+++ b/include/JSystem/JAudio2/JAISeMgr.h
@@ -15,7 +15,7 @@ struct JASNonCopyable {
JASNonCopyable() {}
~JASNonCopyable() {}
- /* 0x0 */ int field_0x0;
+ /* 0x0 */ void* field_0x0;
}; // Size: 0x4
/**
@@ -56,7 +56,7 @@ public:
mParams.init();
mMaxActiveSe = 0;
mMaxInactiveSe = 0;
- field_0x0 = 0;
+ field_0x0 = NULL;
}
virtual bool isUsingSeqData(const JAISeqDataRegion& seqDataRegion);
diff --git a/include/JSystem/JAudio2/JAISound.h b/include/JSystem/JAudio2/JAISound.h
index 5e414ade24..5e1cd40b4b 100644
--- a/include/JSystem/JAudio2/JAISound.h
+++ b/include/JSystem/JAudio2/JAISound.h
@@ -5,6 +5,7 @@
#include "JSystem/JAudio2/JAIAudible.h"
#include "JSystem/JUtility/JUTAssert.h"
#include "global.h"
+#include <cstdint>
class JAISound;
@@ -134,7 +135,7 @@ struct JAISoundStatus_ {
u8 flag8 : 1;
} flags;
} state;
- /* 0x4 */ u32 userdata_;
+ /* 0x4 */ uintptr_t userdata_;
}; // Size: 0x8
/**
@@ -294,8 +295,8 @@ public:
void setAnimationState(u32 state) {
status_.state.flags.animationState = state;
}
- u32 getUserData() const { return status_.userdata_; }
- void setUserData(u32 userData) { status_.userdata_ = userData; }
+ uintptr_t getUserData() const { return status_.userdata_; }
+ void setUserData(uintptr_t userData) { status_.userdata_ = userData; }
JAIAudible* getAudible() { return audible_; }
bool isHandleAttached() const { return handle_ != NULL; }
bool hasLifeTime() const { return status_.field_0x1.flags.flag2; }
diff --git a/include/JSystem/JAudio2/JASDSPInterface.h b/include/JSystem/JAudio2/JASDSPInterface.h
index d68727c9ea..0642fdc018 100644
--- a/include/JSystem/JAudio2/JASDSPInterface.h
+++ b/include/JSystem/JAudio2/JASDSPInterface.h
@@ -112,7 +112,7 @@ namespace JASDsp {
void invalChannelAll();
void initBuffer();
int setFXLine(u8, s16*, JASDsp::FxlineConfig_*);
- BOOL changeFXLineParam(u8, u8, u32);
+ BOOL changeFXLineParam(u8, u8, uintptr_t);
extern u8 const DSPADPCM_FILTER[64];
extern u32 const DSPRES_FILTER[320];
diff --git a/include/JSystem/JAudio2/JASResArcLoader.h b/include/JSystem/JAudio2/JASResArcLoader.h
index 1b375e798e..bcaf1fb06f 100644
--- a/include/JSystem/JAudio2/JASResArcLoader.h
+++ b/include/JSystem/JAudio2/JASResArcLoader.h
@@ -8,10 +8,10 @@ namespace JASResArcLoader {
size_t getResSize(JKRArchive const*, u16);
size_t getResMaxSize(JKRArchive const*);
static void loadResourceCallback(void*);
- int loadResourceAsync(JKRArchive*, u16, u8*, u32, void (*)(u32, u32), u32);
+ int loadResourceAsync(JKRArchive*, u16, u8*, u32, void (*)(u32, uintptr_t), uintptr_t);
// from pikmin2
- typedef void (*LoadCallback)(u32, u32);
+ typedef void (*LoadCallback)(u32, uintptr_t);
struct TLoadResInfo {
inline TLoadResInfo(JKRArchive* archive, u16 id, void* buf, u32 size)
@@ -30,7 +30,7 @@ namespace JASResArcLoader {
void* mBuffer; // _08
u32 mBufferSize; // _0C
LoadCallback mCallback; // _10
- u32 mCallbackArg; // _14, arg to pass to mCallback along with readResource result
+ uintptr_t mCallbackArg; // _14, arg to pass to mCallback along with readResource result
OSMessageQueue* mQueue; // _18
};
};
diff --git a/include/JSystem/JKernel/JKRHeap.h b/include/JSystem/JKernel/JKRHeap.h
index b6675f41b7..e3ce79f00b 100644
--- a/include/JSystem/JKernel/JKRHeap.h
+++ b/include/JSystem/JKernel/JKRHeap.h
@@ -5,6 +5,7 @@
#include <dolphin/os.h>
#include "global.h"
#include <new>
+#include <cstdint>
class JKRHeap;
typedef void (*JKRErrorHandler)(void*, u32, int);
@@ -66,7 +67,7 @@ public:
JKRHeap* find(void* ptr) const;
JKRHeap* findAllHeap(void* ptr) const;
- void dispose_subroutine(u32 start, u32 end);
+ void dispose_subroutine(uintptr_t start, uintptr_t end);
bool dispose(void* ptr, u32 size);
void dispose(void* begin, void* end);
void dispose();
diff --git a/include/JSystem/JStudio/JStudio/fvb-data.h b/include/JSystem/JStudio/JStudio/fvb-data.h
index b88f637dbb..3932d0edc1 100644
--- a/include/JSystem/JStudio/JStudio/fvb-data.h
+++ b/include/JSystem/JStudio/JStudio/fvb-data.h
@@ -14,7 +14,7 @@ extern const char ga4cSignature[4];
const int PARAGRAPH_DATA = 1;
-typedef enum TEComposite {
+enum TEComposite {
/* 0x0 */ COMPOSITE_NONE,
/* 0x1 */ COMPOSITE_RAW,
/* 0x2 */ COMPOSITE_IDX,
diff --git a/include/JSystem/JStudio/JStudio/stb.h b/include/JSystem/JStudio/JStudio/stb.h
index 20813969ff..b17bb57a8c 100644
--- a/include/JSystem/JStudio/JStudio/stb.h
+++ b/include/JSystem/JStudio/JStudio/stb.h
@@ -5,6 +5,7 @@
#include "JSystem/JStudio/JStudio/object-id.h"
#include "JSystem/JStudio/JStudio/stb-data-parse.h"
#include <dolphin/os.h>
+#include <cstdint>
namespace JStudio {
class TObject;
@@ -86,7 +87,7 @@ public:
const void* getSequence() const { return pSequence; }
void setSequence_(const void* arg1) { pSequence = arg1; }
const void* getSequence_offset(s32 i_no) const {
- int s32Val = (s32)getSequence();
+ intptr_t s32Val = (intptr_t)getSequence();
return (const void*)(s32Val + i_no);
}
const void* getSequence_next() const { return pSequence_next; }
diff --git a/include/JSystem/JSupport/JSUOutputStream.h b/include/JSystem/JSupport/JSUOutputStream.h
index b44ec084b0..b7ab069fbb 100644
--- a/include/JSystem/JSupport/JSUOutputStream.h
+++ b/include/JSystem/JSupport/JSUOutputStream.h
@@ -18,30 +18,24 @@ public:
s32 write(const void*, s32);
void write(const char*);
- JSUOutputStream& operator<<(u32 param_0) {
- write(&param_0, sizeof(u32));
- return *this;
- }
-
- JSUOutputStream& operator<<(s32 param_0) {
- write(&param_0, sizeof(s32));
- return *this;
- }
-
- JSUOutputStream& operator<<(s16 param_0) {
- write(&param_0, sizeof(s16));
- return *this;
- }
-
- JSUOutputStream& operator<<(u16 param_0) {
- write(&param_0, sizeof(u16));
- return *this;
+#define JSU_OUTPUTSTREAM_OPERATOR(T) \
+ JSUOutputStream& operator<<(T val) { \
+ write(&val, sizeof(T)); \
+ return *this; \
}
- JSUOutputStream& operator<<(u8 param_0) {
- write(&param_0, sizeof(u8));
- return *this;
- }
+ JSU_OUTPUTSTREAM_OPERATOR(signed char)
+ JSU_OUTPUTSTREAM_OPERATOR(unsigned char)
+ JSU_OUTPUTSTREAM_OPERATOR(signed short)
+ JSU_OUTPUTSTREAM_OPERATOR(unsigned short)
+ JSU_OUTPUTSTREAM_OPERATOR(int)
+ JSU_OUTPUTSTREAM_OPERATOR(unsigned int)
+ JSU_OUTPUTSTREAM_OPERATOR(signed long)
+ JSU_OUTPUTSTREAM_OPERATOR(unsigned long)
+ JSU_OUTPUTSTREAM_OPERATOR(signed long long)
+ JSU_OUTPUTSTREAM_OPERATOR(unsigned long long)
+
+#undef JSU_OUTPUTSTREAM_OPERATOR
JSUOutputStream& operator<<(const char* param_0) {
write(param_0);
diff --git a/include/JSystem/JSupport/JSupport.h b/include/JSystem/JSupport/JSupport.h
index 717fd9b7b0..c982af6103 100644
--- a/include/JSystem/JSupport/JSupport.h
+++ b/include/JSystem/JSupport/JSupport.h
@@ -20,7 +20,7 @@ T* JSUConvertOffsetToPtr(const void* ptr, uintptr_t offset) {
template <typename T>
T* JSUConvertOffsetToPtr(const void* ptr, const void* offset) {
T* ret;
- if (offset == NULL) {
+ if (offset == 0) {
ret = NULL;
} else {
ret = (T*)((intptr_t)ptr + (intptr_t)offset);
diff --git a/include/JSystem/JUtility/JUTXfb.h b/include/JSystem/JUtility/JUTXfb.h
index 28059c7073..c4bf605b9c 100644
--- a/include/JSystem/JUtility/JUTXfb.h
+++ b/include/JSystem/JUtility/JUTXfb.h
@@ -75,7 +75,7 @@ private:
static JUTXfb* sManager;
private:
- /* 0x00 */ void* mBuffer[3];
+ /* 0x00 */ u8* mBuffer[3];
/* 0x0C */ bool mXfbAllocated[3];
/* 0x10 */ s32 mBufferNum;
/* 0x14 */ s16 mDrawingXfbIndex;