diff --git a/libultraship/Makefile b/libultraship/Makefile index d894514b6..6f087baf6 100644 --- a/libultraship/Makefile +++ b/libultraship/Makefile @@ -18,7 +18,11 @@ WARN := -Wall -Wextra -Werror \ -Wno-parentheses \ -Wno-narrowing \ -Wno-missing-field-initializers \ - -Wno-error=multichar + -Wno-error=multichar \ + -Wno-unused-command-line-argument \ + -Wno-delete-non-abstract-non-virtual-dtor \ + -Wno-unused-private-field \ + -Wno-deprecated-copy-with-user-provided-copy CWARN := CXXWARN := -Wno-deprecated-enum-enum-conversion diff --git a/libultraship/libultraship/Console.cpp b/libultraship/libultraship/Console.cpp index 6708f1bfb..da61e4056 100644 --- a/libultraship/libultraship/Console.cpp +++ b/libultraship/libultraship/Console.cpp @@ -28,7 +28,7 @@ static bool ClearCommand(const std::vector&) { std::string toLowerCase(std::string in) { std::string cpy(in); - std::ranges::transform(cpy, cpy.begin(), [](unsigned char c) { return std::tolower(c); }); + std::transform(cpy.begin(), cpy.end(), cpy.begin(), ::tolower); return cpy; } @@ -204,11 +204,11 @@ void Console::Draw() { for (int i = 0; i < static_cast(channel.size()); i++) { ConsoleLine line = channel[i]; if(!this->filter.empty() && line.text.find(this->filter) == std::string::npos) continue; - if(this->level_filter != NULLSTR && line.priority != (std::ranges::find(priority_filters, this->level_filter) - priority_filters.begin()) - 1) continue; + if(this->level_filter != NULLSTR && line.priority != (std::find(priority_filters.begin(), priority_filters.end(), this->level_filter) - priority_filters.begin()) - 1) continue; std::string id = line.text + "##" + std::to_string(i); ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); - const bool is_selected = (this->selectedId == i) || std::ranges::find(this->selectedEntries, i) != this->selectedEntries.end(); + const bool is_selected = (this->selectedId == i) || std::find(this->selectedEntries.begin(), this->selectedEntries.end(), i) != this->selectedEntries.end(); ImGui::PushStyleColor(ImGuiCol_Text, this->priority_colors[line.priority]); if (ImGui::Selectable(id.c_str(), is_selected)) { if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_LeftCtrl)) && !is_selected) diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index c85550fdd..4597f5a8d 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -1377,7 +1377,7 @@ namespace SohImGui { if (ImGui::BeginMenu(category.first.c_str())) { for (const std::string& name : category.second) { std::string varName(name); - varName.erase(std::ranges::remove_if(varName, isspace).begin(), varName.end()); + varName.erase(std::remove_if(varName.begin(), varName.end(), [](unsigned char x) { return std::isspace(x); }), varName.end()); std::string toggleName = "g" + varName + "Enabled"; EnhancementCheckbox(name.c_str(), toggleName.c_str()); diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp index 89019aa97..9e1117c37 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp @@ -566,7 +566,7 @@ static bool gfx_texture_cache_lookup(int i, int tile) { static void gfx_texture_cache_delete(const uint8_t* orig_addr) { while (gfx_texture_cache.map.bucket_count() > 0) { - TextureCacheKey key = { orig_addr, 0, 0, 0 }; // bucket index only depends on the address + TextureCacheKey key = { orig_addr, {0}, 0, 0 }; // bucket index only depends on the address size_t bucket = gfx_texture_cache.map.bucket(key); bool again = false; for (auto it = gfx_texture_cache.map.begin(bucket); it != gfx_texture_cache.map.end(bucket); ++it) { diff --git a/libultraship/libultraship/mixer.c b/libultraship/libultraship/mixer.c index 1e66dc8a1..2e80ffb16 100644 --- a/libultraship/libultraship/mixer.c +++ b/libultraship/libultraship/mixer.c @@ -4,7 +4,9 @@ #include "mixer.h" +#ifndef __clang__ #pragma GCC optimize ("unroll-loops") +#endif #define ROUND_UP_64(v) (((v) + 63) & ~63) #define ROUND_UP_32(v) (((v) + 31) & ~31) @@ -449,10 +451,14 @@ void aFilterImpl(uint8_t flags, uint16_t count_or_buf, int16_t *state_or_filter) int16_t *buf = BUF_S16(count_or_buf); if (flags == A_INIT) { +#ifndef __clang__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmemset-elt-size" +#endif memset(tmp, 0, 8 * sizeof(int16_t)); +#ifndef __clang__ #pragma GCC diagnostic pop +#endif memset(tmp2, 0, 8 * sizeof(int16_t)); } else { memcpy(tmp, state_or_filter, 8 * sizeof(int16_t)); diff --git a/soh/Makefile b/soh/Makefile index 43140dc95..d29e2f990 100644 --- a/soh/Makefile +++ b/soh/Makefile @@ -18,8 +18,11 @@ LTO ?= 0 WARN := \ -Wno-return-type \ + -Wno-unused-command-line-argument \ + -Wno-implicit-function-declaration \ + -Wno-c++11-narrowing \ -funsigned-char \ - -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-strict-aliasing -fno-inline-functions -fno-inline-small-functions -fno-toplevel-reorder -ffreestanding -fwrapv \ + -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-strict-aliasing -fno-inline-functions -fno-inline-small-functions -ffreestanding -fwrapv \ CXXFLAGS := $(WARN) -std=c++20 -D_GNU_SOURCE -fpermissive -no-pie -nostdlib CFLAGS := $(WARN) -std=c99 -D_GNU_SOURCE -no-pie -nostdlib diff --git a/soh/soh/Enhancements/bootcommands.c b/soh/soh/Enhancements/bootcommands.c index fbf1ea5fd..9062fbf28 100644 --- a/soh/soh/Enhancements/bootcommands.c +++ b/soh/soh/Enhancements/bootcommands.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index e96942893..1fe98ab53 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -509,7 +509,7 @@ void DebugConsole_LoadCVars() if (cfg.size() < 2) continue; if (cfg[1].find("\"") != std::string::npos) { std::string value(cfg[1]); - value.erase(std::ranges::remove(value, '\"').begin(), value.end()); + value.erase(std::remove(value.begin(), value.end(), '\"'), value.end()); CVar_SetString(cfg[0].c_str(), ImStrdup(value.c_str())); } if (is_number(cfg[1])) { diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index eff66f700..251f321ae 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1327,17 +1327,17 @@ extern "C" int16_t OTRGetRectDimensionFromRightEdge(float v) { } extern "C" void bswapSoundFontSound(SoundFontSound* swappable) { - swappable->sample = (SoundFontSample*)BOMSWAP32((u32)swappable->sample); - swappable->tuningAsU32 = BOMSWAP32((u32)swappable->tuningAsU32); + swappable->sample = (SoundFontSample*)BOMSWAP32((u32)(uintptr_t(swappable->sample))); + swappable->tuningAsU32 = BOMSWAP32((u32)(swappable->tuningAsU32 & 0xFFFFFFFF)); } extern "C" void bswapDrum(Drum* swappable) { bswapSoundFontSound(&swappable->sound); - swappable->envelope = (AdsrEnvelope*)BOMSWAP32((u32)swappable->envelope); + swappable->envelope = (AdsrEnvelope*)BOMSWAP32((u32)uintptr_t(swappable->envelope)); } extern "C" void bswapInstrument(Instrument* swappable) { - swappable->envelope = (AdsrEnvelope*)BOMSWAP32((u32)swappable->envelope); + swappable->envelope = (AdsrEnvelope*)BOMSWAP32((u32)uintptr_t(swappable->envelope)); bswapSoundFontSound(&swappable->lowNotesSound); bswapSoundFontSound(&swappable->normalNotesSound); bswapSoundFontSound(&swappable->highNotesSound); @@ -1352,9 +1352,9 @@ extern "C" void bswapSoundFontSample(SoundFontSample* swappable) { swappable->unk_bit25 = (origBitfield >> 21) & 0x01; swappable->size = (origBitfield) & 0x00FFFFFF; - swappable->sampleAddr = (u8*)BOMSWAP32((u32)swappable->sampleAddr); - swappable->loop = (AdpcmLoop*)BOMSWAP32((u32)swappable->loop); - swappable->book = (AdpcmBook*)BOMSWAP32((u32)swappable->book); + swappable->sampleAddr = (u8*)BOMSWAP32((u32)uintptr_t(swappable->sampleAddr)); + swappable->loop = (AdpcmLoop*)BOMSWAP32((u32)uintptr_t(swappable->loop)); + swappable->book = (AdpcmBook*)BOMSWAP32((u32)uintptr_t(swappable->book)); } extern "C" void bswapAdpcmLoop(AdpcmLoop* swappable) { diff --git a/soh/soh/gu_pc.c b/soh/soh/gu_pc.c index 7bdcded98..be1954a5d 100644 --- a/soh/soh/gu_pc.c +++ b/soh/soh/gu_pc.c @@ -1,3 +1,4 @@ +#include #include "z64.h" void guMtxF2L(float mf[4][4], Mtx* m) { @@ -84,4 +85,4 @@ void guNormalize(f32* x, f32* y, f32* z) { *x = *x * tmp; *y = *y * tmp; *z = *z * tmp; -} \ No newline at end of file +} diff --git a/soh/src/code/game.c b/soh/src/code/game.c index 69b7c0ef7..3bcdfcde0 100644 --- a/soh/src/code/game.c +++ b/soh/src/code/game.c @@ -1,3 +1,4 @@ +#include #include "global.h" #include "vt.h" @@ -9,6 +10,9 @@ ViMode sViMode; FaultClient sGameFaultClient; u16 sLastButtonPressed; +// Forward declared, because this in a C++ header. +int gfx_create_framebuffer(uint32_t width, uint32_t height); + void GameState_FaultPrint(void) { static char sBtnChars[] = "ABZSuldr*+LRudlr"; s32 i;