From 30f5540590233b86bc0cef563ef8de83a12dfaa0 Mon Sep 17 00:00:00 2001 From: Sancho Date: Mon, 27 Nov 2023 23:14:08 +0100 Subject: [PATCH] foerr: Fix Windows build MSVC doesn't know what an uint is. Add missing includes for consts.hpp where it is typedefed. Don't use designated initializers, as apparently this feature is C++20 and MSVC really doesn't like it. Initialize some random bool variable which causes a runtime error on Windows. Signed-off-by: h67ma --- deps/sfml/CMakeLists.txt | 8 ++++++++ src/campaigns/room.cpp | 3 ++- src/campaigns/room_cell.hpp | 1 + src/hud/log.hpp | 1 + src/hud/sliders/slider_handle.hpp | 1 + src/hud/text_label.hpp | 1 + src/materials/material_manager.cpp | 18 +++++++++--------- src/util/util.hpp | 2 ++ 8 files changed, 25 insertions(+), 10 deletions(-) diff --git a/deps/sfml/CMakeLists.txt b/deps/sfml/CMakeLists.txt index f826745..34e0952 100644 --- a/deps/sfml/CMakeLists.txt +++ b/deps/sfml/CMakeLists.txt @@ -19,4 +19,12 @@ set(SFML_BUILD_TEST_SUITE OFF) message(STATUS "Fetching SFML...") FetchContent_MakeAvailable(sfml) +if(WIN32) + # /EHsc is to somehow mitigate warning C4530 (being treated as an error) + target_compile_options(sfml-audio PRIVATE /EHsc) + target_compile_options(sfml-graphics PRIVATE /EHsc) + target_compile_options(sfml-system PRIVATE /EHsc) + target_compile_options(sfml-window PRIVATE /EHsc) +endif() + # TODO copy openal.dll from sfml-src/extlibs/bin/{x64/x86} to root dir or somehow add it to PATH diff --git a/src/campaigns/room.cpp b/src/campaigns/room.cpp index 84f335d..2c271e8 100644 --- a/src/campaigns/room.cpp +++ b/src/campaigns/room.cpp @@ -10,6 +10,7 @@ #include #include +#include "../consts.hpp" #include "../hud/log.hpp" #include "../objects/back_obj.hpp" #include "../settings/settings_manager.hpp" @@ -354,7 +355,7 @@ void Room::setupBackHoleObjects(ResourceManager& resMgr, const ObjectManager& ob } // both backObjMain and backObjHole are expected to have textures, don't check if they are nullptr - this->backHoleObjectsMain.push_back({ .spriteRes = backObjMain, .blend = blend }); + this->backHoleObjectsMain.push_back({ backObjMain, blend }); this->backHoleObjectsHoles.push_back(backObjHole); } } diff --git a/src/campaigns/room_cell.hpp b/src/campaigns/room_cell.hpp index e045add..04bdc0a 100644 --- a/src/campaigns/room_cell.hpp +++ b/src/campaigns/room_cell.hpp @@ -10,6 +10,7 @@ #include #include +#include "../consts.hpp" #include "../materials/material_manager.hpp" #include "../resources/resource_manager.hpp" #include "../resources/sprite_resource.hpp" diff --git a/src/hud/log.hpp b/src/hud/log.hpp index 61395bd..0d12939 100644 --- a/src/hud/log.hpp +++ b/src/hud/log.hpp @@ -15,6 +15,7 @@ #include #include +#include "../consts.hpp" #include "../hud/hud.hpp" #include "../settings/settings_manager.hpp" #include "../util/util.hpp" diff --git a/src/hud/sliders/slider_handle.hpp b/src/hud/sliders/slider_handle.hpp index 6e94bf3..25f1a20 100644 --- a/src/hud/sliders/slider_handle.hpp +++ b/src/hud/sliders/slider_handle.hpp @@ -9,6 +9,7 @@ #include #include +#include "../../consts.hpp" #include "../configurable_gui_component.hpp" constexpr float SLIDER_HANDLE_HEIGHT = 15; diff --git a/src/hud/text_label.hpp b/src/hud/text_label.hpp index 5a9d079..4f062c9 100644 --- a/src/hud/text_label.hpp +++ b/src/hud/text_label.hpp @@ -9,6 +9,7 @@ #include #include +#include "../consts.hpp" #include "configurable_gui_component.hpp" /** diff --git a/src/materials/material_manager.cpp b/src/materials/material_manager.cpp index fda0d07..c1b870b 100644 --- a/src/materials/material_manager.cpp +++ b/src/materials/material_manager.cpp @@ -72,7 +72,7 @@ bool MaterialManager::loadMap(const nlohmann::json& root, std::unordered_map(matNode.value(), std::string(PATH_MATERIALS), FOERR_JSON_KEY_IS_RIGHT, matIsRight)) @@ -93,14 +93,14 @@ bool MaterialManager::loadMap(const nlohmann::json& root, std::unordered_map +#include "../consts.hpp" + #define STR(thing) #thing #define STR_EXP(thing) STR(thing) // "the double expansion trick"