Skip to content

Commit b4b78bc

Browse files
committed
Only use the __CWCC__ macro to test for cwcc
1 parent 2978fbf commit b4b78bc

File tree

15 files changed

+47
-33
lines changed

15 files changed

+47
-33
lines changed

.clangd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CompileFlags:
2+
Add: [-D__CLANGD__]

include/decomp.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ typedef struct ps_f32 {
2525
SECTION_GARBAGE static void __garbage_ordering_hints(void)
2626
#define order_hint_access(var) (void)(var)
2727

28-
#elif defined (__INTELLISENSE__)
28+
#elif defined (__EDITOR_CHECKING__)
29+
// dummy implementations for editor tooling
2930

3031
#define sdata_ps_f32 ps_f32
3132
#define sdata2_ps_f32 ps_f32
@@ -35,9 +36,5 @@ typedef struct ps_f32 {
3536
#define SECTION_GARBAGE
3637
#define static_order_hints
3738
#define order_hint_access(var) (void)(var)
38-
39-
#endif
40-
41-
#ifdef __clang__
42-
#define __cntlzw(x) __builtin_clz(x)
39+
#define __cntlzw(x) (x)
4340
#endif

include/macros.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,20 @@
2424

2525
#define DECLTYPE(x) __decltype__(x)
2626

27-
// https://github.com/DarkRTA/rb3/blob/235050f88a263fec0387b7c618dda76a8bb24d2c/src/sdk/RVL_SDK/revolution/os/OSUtils.h#L13-L17
28-
#if defined(__MWERKS__) && !defined(__INTELLISENSE__)
29-
#define AT_ADDRESS(addr) : (addr)
30-
#else
31-
#define AT_ADDRESS(addr)
27+
#if defined(__INTELLISENSE__) || defined(__CLANGD__)
28+
#define __EDITOR_CHECKING__
3229
#endif
3330

34-
// For VSCode
35-
#ifdef __INTELLISENSE__
31+
#ifdef __CWCC__
32+
// codewarrior-specific syntax
33+
#define AT_ADDRESS(addr) : (addr)
34+
#elif defined(__EDITOR_CHECKING__)
35+
// dummy implementations for editor tooling
36+
#define AT_ADDRESS(addr)
3637
#define asm
3738
#define __attribute__(x)
3839
#define __declspec(x)
40+
#else
41+
// building with a non-codewarrior compiler is not supported yet
42+
#error "workarounds for codewarrior's language extensions unimplemented"
3943
#endif

include/rk_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class NonCopyable {
111111

112112

113113
// Main static assert macro
114-
#if defined(__INTELLISENSE__)
114+
#ifdef __EDITOR_CHECKING__
115115
#if !__has_extension(c_static_assert)
116116
#error "language server lacks `_Static_assert` support"
117117
#endif

lib/MSL/include/math.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,14 @@ inline f32 sqrtf(f32 x) { return (f32)sqrt(x); }
2525
f64 acos(f64);
2626
inline f32 acosf(f32 x) { return (f32)acos(x); }
2727

28-
#ifdef __INTELLISENSE__
29-
#define __fabsf(x) x
30-
#define __fabs(x) x
28+
#ifdef __CWCC__
29+
// when using the codewarrior compiler, __fabs and __fabsf are builtin intrinsics.
30+
#elif defined(__EDITOR_CHECKING__)
31+
// dummy implementation for editor tooling
32+
#define __fabsf(x) (x)
33+
#define __fabs(x) (x)
34+
#else
35+
#error "attempted to compile MSL (Metrowerks Standard Library) header with non-codewarrior compiler"
3136
#endif
3237

3338
f32 fabsf(f32);

lib/MSL/include/stddef.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#pragma once
22

3-
#ifdef __INTELLISENSE__
3+
#include "macros.h"
4+
5+
#ifdef __EDITOR_CHECKING__
46
#define offsetof(type, m) __builtin_offsetof(type,m)
57
#else
68
#define offsetof(type, m) ((size_t) & (((type*)0)->m))

lib/MSL/include/stdlib.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#include "macros.h"
4+
35
#ifndef SIZE_T_DEFINE
46
#define SIZE_T_DEFINE
57
typedef unsigned long size_t;
@@ -9,11 +11,12 @@ typedef unsigned long size_t;
911
#ifdef __CWCC__
1012
#define abs(x) __abs(x)
1113
#define labs(x) __labs(x)
12-
#elif defined(__clang__)
13-
#define abs(x) __builtin_abs(x)
14-
#define labs(x) __builtin_labs(x)
14+
#elif defined(__EDITOR_CHECKING__)
15+
// dummy implementation for editor tooling
16+
#define abs(x) (x)
17+
#define labs(x) (x)
1518
#else
16-
#error compiler has no instrinsic abs support, please do some sit ups.
19+
#error "attempted to compile MSL (Metrowerks Standard Library) header with non-codewarrior compiler"
1720
#endif
1821

1922
long strtol(const char* restrict nptr, char** restrict endptr, int base);

lib/gamespy/gt2/gt2Utility.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ unsigned int** gt2StringToIPs(const char* string) {
230230
** INTERNAL FUNCTIONS **
231231
***********************/
232232

233-
#ifdef __MWERKS__ // CodeWarrior will warn if not prototyped
233+
#ifdef __CWCC__ // CodeWarrior will warn if not prototyped
234234
void gti2MessageCheck(const GT2Byte** message, int* len);
235235
#endif
236236

lib/gamespy/qr2/qr2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ INCLUDES
1111
extern "C" {
1212
#endif
1313

14-
#ifdef __MWERKS__ // Codewarrior requires function prototypes
14+
#ifdef __CWCC__ // Codewarrior requires function prototypes
1515
qr2_error_t qr2_initW(/*[out]*/ qr2_t* qrec, const unsigned short* ip,
1616
int baseport, const unsigned short* gamename,
1717
const unsigned short* secret_key, int ispublic,

lib/gamespy/qr2/qr2regkeys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "../common/gsDebug.h"
55
#include "../common/gsStringUtil.h"
66

7-
#ifdef __MWERKS__ // CodeWarrior requires prototypes
7+
#ifdef __CWCC__ // CodeWarrior requires prototypes
88
void qr2_register_keyW(int keyid, const unsigned short* key);
99
void qr2_register_keyA(int keyid, const char* key);
1010
#endif

0 commit comments

Comments
 (0)