Skip to content

Commit d6dec3d

Browse files
authored
Code cleanup to fix warnings on Windows and macOS builds, added -dump-memory option (#304)
* Add defaults to switch statements * CReal3D: Fixed warnings, moved default initialization from constructor to class declaration * CLegacy3D: Fix warnings * CNew3D: fixed warnings about member order initialization in constructor * Fixed warnings * New3D engine: fixed offsetof() warnings * PowerPC disassembler: sprintf() -> snprintf() and bumped its version number up * Added -dump-memory option * ppcd: Fixed potential segfault * Input.cpp: fix constructor initializer list order * 53C810.cpp: Fixed warning about extraneous parentheses * Update copyright headers * Z80.cpp: Remove pointless self assignments (were these ANDed with 0xffff at some point?) * Updated copyright header * Musashi: Fixed warnings * Update copyright header * SCSP.cpp: Removed non-functional placeholders * Main.cpp: Commented out debug callback * ppc.cpp: ppc_set_cr() for entire CR register was never used * DSB.cpp: stateName table only used by a commented-out printf, turned that into a DebugLog * New3D engine: Fixed warnings in R3DScrollFog * GameLoader.cpp: Fix warnings * Audio.cpp: Fixed warnings * Pragma is MSVC-specific * Makefile.OSX: Suppress deprecation warnings for gluPerspective() * Logger.cpp: fixed warning about format string not being a string literal when using syslog() * Makefile.OSX: remove -s option from link step * CModel3: Fixed sign mismatch warning * ppc_ops.c: Fix FP environment pragmas to support MSVC, clang, and gcc properly * ppc.cpp: Fixed sign warning * DirectInputSystem: Fixed various warnings * SDLInputSystem: Fix sign warnings * Input.cpp: Fix string assembly warning * Fixed CReal3D warnings about sentinel sign and fixed a bit cast * Main.cpp: Fixed sign warnings * Makefiles/Rules.inc: Disable warnings for glew.c, which is a third-party file * SCSP.cpp: Fixed type punning error * Ian's preferred fix for offsetof(): composition with Vertex
1 parent fe00551 commit d6dec3d

36 files changed

Lines changed: 379 additions & 319 deletions

Makefiles/Makefile.OSX

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
##
22
## Supermodel
33
## A Sega Model 3 Arcade Emulator.
4-
## Copyright 2003-2025 The Supermodel Team
4+
## Copyright 2003-2026 The Supermodel Team
55
##
66
## This file is part of Supermodel.
77
##
@@ -102,6 +102,12 @@ PLATFORM_SRC_FILES = \
102102

103103
include Makefiles/Rules.inc
104104

105+
# -s (strip) is obsolete and ignored by Apple ld64; remove it to avoid potential warnings
106+
LDOPT := $(filter-out -s,$(LDOPT))
107+
108+
# Suppress gluPerspective deprecation warnings (macOS only, deprecated since 10.9)
109+
$(OBJ_DIR)/Legacy3D.o: CXXFLAGS += -Wno-deprecated-declarations
110+
105111
clean:
106112
$(SILENT)echo Cleaning up \"Frameworks\", \"$(BIN_DIR)\" and \"$(OBJ_DIR)\"...
107113
$(SILENT)$(DELETE) $(BIN_DIR)

Makefiles/Rules.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ $(OBJ_DIR)/%.o: %.cpp | $(OBJ_DIR)
367367
$(info Compiling : $< -> $@)
368368
$(SILENT)$(CXX) $(CXXFLAGS) $< -o $@
369369
370+
# Suppress all warnings for third-party packages that we cannot modify
371+
$(OBJ_DIR)/glew.o: CFLAGS += -w
372+
370373
$(OBJ_DIR)/%.o: %.c | $(OBJ_DIR)
371374
$(info Generating dependencies: $< -> $(OBJ_DIR)/$(*F).d)
372375
$(SILENT)$(CC) -MM -MP -MT $(OBJ_DIR)/$(*F).o -MT $(OBJ_DIR)/$(*F).d $(CFLAGS) $< > $(OBJ_DIR)/$(*F).d

Src/CPU/68K/Musashi/m68kcpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
** Supermodel
33
** A Sega Model 3 Arcade Emulator.
4-
** Copyright 2011 Bart Trzynadlowski, Nik Henson
4+
** Copyright 2003-2026 The Supermodel Team
55
**
66
** This file is part of Supermodel.
77
**

Src/CPU/68K/Musashi/m68kctx.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
** Supermodel
33
** A Sega Model 3 Arcade Emulator.
4-
** Copyright 2011 Bart Trzynadlowski, Nik Henson
4+
** Copyright 2003-2026 The Supermodel Team
55
**
66
** This file is part of Supermodel.
77
**
@@ -72,7 +72,7 @@ typedef struct
7272
UINT32 cyc_shift;
7373
UINT32 cyc_reset;
7474
UINT8* cyc_instruction;
75-
UINT8* cyc_exception;
75+
const UINT8* cyc_exception;
7676

7777
/* Callbacks to host */
7878
int (*int_ack_callback)(int int_line); /* Interrupt Acknowledge */

Src/CPU/68K/Musashi/m68kmake.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
** Supermodel
33
** A Sega Model 3 Arcade Emulator.
4-
** Copyright 2011 Bart Trzynadlowski, Nik Henson
4+
** Copyright 2003-2026 The Supermodel Team
55
**
66
** This file is part of Supermodel.
77
**
@@ -698,7 +698,11 @@ opcode_struct* find_opcode(char* name, int size, char* spec_proc, char* spec_ea)
698698
opcode_struct* op;
699699

700700

701-
for(op = g_opcode_input_table;op->name != NULL;op++)
701+
/* Note: original Musashi code used 'op->name != NULL' here, but op->name is a char array
702+
* (not a pointer), so that comparison is always true and would loop forever if no match
703+
* were found. In practice the loop always exits early via 'return op'. The correct
704+
* sentinel check is an empty name string from the zero-initialized table. */
705+
for(op = g_opcode_input_table;op->name[0] != '\0';op++)
702706
{
703707
if( strcmp(name, op->name) == 0 &&
704708
(size == op->size) &&
@@ -714,7 +718,11 @@ opcode_struct* find_illegal_opcode(void)
714718
{
715719
opcode_struct* op;
716720

717-
for(op = g_opcode_input_table;op->name != NULL;op++)
721+
/* Note: original Musashi code used 'op->name != NULL' here, but op->name is a char array
722+
* (not a pointer), so that comparison is always true and would loop forever if no match
723+
* were found. In practice the loop always exits early via 'return op'. The correct
724+
* sentinel check is an empty name string from the zero-initialized table. */
725+
for(op = g_opcode_input_table;op->name[0] != '\0';op++)
718726
{
719727
if(strcmp(op->name, "illegal") == 0)
720728
return op;

0 commit comments

Comments
 (0)