diff options
| author | Luke Street <luke@street.dev> | 2026-02-28 21:19:17 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-28 20:19:17 -0800 |
| commit | 6a48380461bc9baabe1706ba57ca0cedfa2d0c51 (patch) | |
| tree | 593e054cfcb0250e63917c58b445a7e1f025a023 /include/JSystem/JSupport | |
| parent | b5d3b8c059c10711370437f7db7539cd90f1cb29 (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/JSupport')
| -rw-r--r-- | include/JSystem/JSupport/JSUOutputStream.h | 38 | ||||
| -rw-r--r-- | include/JSystem/JSupport/JSupport.h | 2 |
2 files changed, 17 insertions, 23 deletions
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(¶m_0, sizeof(u32)); - return *this; - } - - JSUOutputStream& operator<<(s32 param_0) { - write(¶m_0, sizeof(s32)); - return *this; - } - - JSUOutputStream& operator<<(s16 param_0) { - write(¶m_0, sizeof(s16)); - return *this; - } - - JSUOutputStream& operator<<(u16 param_0) { - write(¶m_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(¶m_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); |
