From 1abb4bf1d6c26d219c4efb89f1008f7f3a54476f Mon Sep 17 00:00:00 2001 From: qudix <17361645+qudix@users.noreply.github.com> Date: Sun, 3 Nov 2024 20:48:30 -0600 Subject: [PATCH] fix: clang-cl & msvc warnings (#295) --- .github/workflows/main_ci_xmake.yml | 8 ++++---- include/RE/B/BSScriptUtil.h | 1 - include/RE/B/BSTSmartPointer.h | 2 +- include/RE/E/Events.h | 12 +++++++++++- include/RE/I/IMenu.h | 2 +- include/RE/I/idLogging.h | 2 +- include/RE/M/MenuOpenCloseEvent.h | 15 --------------- include/RE/P/PlayerCharacter.h | 6 +++--- include/RE/Starfield.h | 1 - include/RE/T/TESNPC.h | 3 ++- include/RE/T/TESPackage.h | 7 ++++++- include/RE/U/UI.h | 4 ++-- src/RE/Starfield.cpp | 19 +++++++++++++++++++ xmake.lua | 17 ++++++++++++++++- 14 files changed, 66 insertions(+), 33 deletions(-) delete mode 100644 include/RE/M/MenuOpenCloseEvent.h create mode 100644 src/RE/Starfield.cpp diff --git a/.github/workflows/main_ci_xmake.yml b/.github/workflows/main_ci_xmake.yml index 2093d634..6c5b2c06 100644 --- a/.github/workflows/main_ci_xmake.yml +++ b/.github/workflows/main_ci_xmake.yml @@ -17,9 +17,9 @@ jobs: strategy: fail-fast: false matrix: - mode: - - debug - - release + toolchain: + - msvc + - clang-cl steps: - name: Checkout uses: actions/checkout@v4 @@ -30,7 +30,7 @@ jobs: xmake-version: "latest" - name: Configure - run: xmake config -y --mode=${{ matrix.mode }} --vs_toolset=14.41 + run: xmake config -y --mode=releasedbg --toolchain=${{ matrix.toolchain }} --vs_toolset=14.41 - name: Build run: xmake build -y -vD diff --git a/include/RE/B/BSScriptUtil.h b/include/RE/B/BSScriptUtil.h index 42eaeba0..fd08d6ba 100644 --- a/include/RE/B/BSScriptUtil.h +++ b/include/RE/B/BSScriptUtil.h @@ -589,7 +589,6 @@ namespace RE::BSScript void PackVariable(Variable& a_var, T&& a_val) // requires(detail::array>) { - using value_type = detail::decay_t::value_type>; using reference_type = std::conditional_t< std::is_lvalue_reference_v, diff --git a/include/RE/B/BSTSmartPointer.h b/include/RE/B/BSTSmartPointer.h index de068f25..c3c94dd4 100644 --- a/include/RE/B/BSTSmartPointer.h +++ b/include/RE/B/BSTSmartPointer.h @@ -20,7 +20,7 @@ namespace RE struct BSTSmartPointerAutoPtr { public: - constexpr static void Acquire(stl::not_null a_ptr) { return; } + constexpr static void Acquire(stl::not_null) { return; } static void Release(stl::not_null a_ptr) { delete a_ptr; } }; diff --git a/include/RE/E/Events.h b/include/RE/E/Events.h index 88d3a87f..a62c5df4 100644 --- a/include/RE/E/Events.h +++ b/include/RE/E/Events.h @@ -1,6 +1,7 @@ #pragma once #include "RE/B/BSCoreTypes.h" +#include "RE/B/BSFixedString.h" #include "RE/B/BSPointerHandle.h" #include "RE/B/BSTEvent.h" #include "RE/N/NiSmartPointer.h" @@ -1705,6 +1706,14 @@ namespace RE } }; + struct MenuOpenCloseEvent + { + // members + BSFixedString menuName; // 00 + bool opening; // 08 + }; + static_assert(sizeof(MenuOpenCloseEvent) == 0x10); + struct MessageBoxMenu_OnBackOut { [[nodiscard]] static BSTEventSource* GetEventSource() @@ -2253,7 +2262,8 @@ namespace RE enum class Type : std::uint32_t { kNone = static_cast>(-1), - kSteal, + + kSteal = 0, kPickpocket, kTrespass, kAttack, diff --git a/include/RE/I/IMenu.h b/include/RE/I/IMenu.h index 2a2ab648..b9e9aef3 100644 --- a/include/RE/I/IMenu.h +++ b/include/RE/I/IMenu.h @@ -119,7 +119,7 @@ namespace RE virtual std::uint64_t Unk10() // 10 { using func_t = decltype(&IMenu::Unk10); - static REL::Relocation func(REL::ID(187241)); + static REL::Relocation func(REL::ID(187241)); return func(this); }; diff --git a/include/RE/I/idLogging.h b/include/RE/I/idLogging.h index d82ddfdd..51585072 100644 --- a/include/RE/I/idLogging.h +++ b/include/RE/I/idLogging.h @@ -36,7 +36,7 @@ namespace RE } }; - [[nodiscard]] static ILogger* GetLoggerSingleton() + [[nodiscard]] inline ILogger* GetLoggerSingleton() { static REL::Relocation singleton{ ID::idLogging::Singleton }; return *singleton; diff --git a/include/RE/M/MenuOpenCloseEvent.h b/include/RE/M/MenuOpenCloseEvent.h deleted file mode 100644 index 969b6512..00000000 --- a/include/RE/M/MenuOpenCloseEvent.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "RE/B/BSFixedString.h" - -namespace RE -{ - class MenuOpenCloseEvent - { - public: - // members - BSFixedString menuName; // 00 - bool opening; // 08 - }; - static_assert(sizeof(MenuOpenCloseEvent) == 0x10); -} diff --git a/include/RE/P/PlayerCharacter.h b/include/RE/P/PlayerCharacter.h index 461a05b0..5295f132 100644 --- a/include/RE/P/PlayerCharacter.h +++ b/include/RE/P/PlayerCharacter.h @@ -5,18 +5,18 @@ namespace RE { - class MenuModeChangeEvent; - class MenuOpenCloseEvent; class OtherEventEnabledEvent; - class TESHitEvent; class UserEventEnabledEvent; struct AnimationGraphDependentEvent; struct BGSActorCellEvent; struct BGSActorDeathEvent; + struct MenuModeChangeEvent; + struct MenuOpenCloseEvent; struct PickRefUpdateEvent; struct PositionPlayerEvent; struct TargetHitEvent; + struct TESHitEvent; struct TESFormDeleteEvent; struct QuestStatus diff --git a/include/RE/Starfield.h b/include/RE/Starfield.h index 739c1316..918b07eb 100644 --- a/include/RE/Starfield.h +++ b/include/RE/Starfield.h @@ -306,7 +306,6 @@ #include "RE/M/MagicTarget.h" #include "RE/M/Main.h" #include "RE/M/MemoryManager.h" -#include "RE/M/MenuOpenCloseEvent.h" #include "RE/M/MenuPaperDoll.h" #include "RE/M/MenuTopicManager.h" #include "RE/M/Misc.h" diff --git a/include/RE/T/TESNPC.h b/include/RE/T/TESNPC.h index a66eba4d..c5ea6c18 100644 --- a/include/RE/T/TESNPC.h +++ b/include/RE/T/TESNPC.h @@ -20,12 +20,13 @@ namespace RE class BGSListForm; class BGSOutfit; class BGSRelationship; - class MenuOpenCloseEvent; class TESClass; class TESCombatStyle; class TESFaction; class TESFurniture; + struct MenuOpenCloseEvent; + class __declspec(novtable) TESNPC : public TESActorBase, // 000 public TESRaceForm, // 278 diff --git a/include/RE/T/TESPackage.h b/include/RE/T/TESPackage.h index d332383f..33076ad7 100644 --- a/include/RE/T/TESPackage.h +++ b/include/RE/T/TESPackage.h @@ -24,15 +24,20 @@ namespace RE struct PackageTarget { + // members std::uint8_t type; + // TODO: warning C4624: 'PackageTarget': destructor was implicitly defined as deleted + /* union { BSPointerHandle refHandle; TESForm* object; }; std::int32_t value; + */ }; - static_assert(sizeof(PackageTarget) == 0x18); + //static_assert(sizeof(PackageTarget) == 0x18); + class __declspec(novtable) TESPackage : public TESForm // 00 diff --git a/include/RE/U/UI.h b/include/RE/U/UI.h index cc4a5db4..7eace9f4 100644 --- a/include/RE/U/UI.h +++ b/include/RE/U/UI.h @@ -8,8 +8,6 @@ namespace RE { class IMenu; - class MenuOpenCloseEvent; - class MenuModeChangeEvent; namespace Scaleform { @@ -21,6 +19,8 @@ namespace RE struct BIUIMenuVisiblePausedEndEvent; struct BSCursorRotationChange; struct BSCursorTypeChange; + struct MenuModeChangeEvent; + struct MenuOpenCloseEvent; struct MenuPauseChangeEvent; struct MenuPauseCounterChangeEvent; struct TutorialEvent; diff --git a/src/RE/Starfield.cpp b/src/RE/Starfield.cpp new file mode 100644 index 00000000..957e7c43 --- /dev/null +++ b/src/RE/Starfield.cpp @@ -0,0 +1,19 @@ +#include "RE/Starfield.h" + +namespace RE +{ + namespace detail + { + template class BSFixedString; + static_assert(sizeof(BSFixedString) == 0x8); + + template class BSFixedString; + static_assert(sizeof(BSFixedString) == 0x8); + + template class BSFixedString; + static_assert(sizeof(BSFixedString) == 0x8); + + template class BSFixedString; + static_assert(sizeof(BSFixedString) == 0x8); + } +} diff --git a/xmake.lua b/xmake.lua index 2002bf2b..ab4d5dbe 100644 --- a/xmake.lua +++ b/xmake.lua @@ -116,10 +116,25 @@ target("commonlibsf") "cl::/wd5220" -- 'member': a non-static data member with a volatile qualified type no longer implies that compiler generated copy / move constructors and copy / move assignment operators are not trivial ) + -- add flags (clang-cl) + add_cxxflags( + "clang_cl::-fms-compatibility", + "clang_cl::-fms-extensions", + { public = true } + ) + -- add flags (clang-cl: disable warnings) add_cxxflags( "clang_cl::-Wno-delete-non-abstract-non-virtual-dtor", + "clang_cl::-Wno-deprecated-volatile", + "clang_cl::-Wno-ignored-qualifiers", "clang_cl::-Wno-inconsistent-missing-override", + "clang_cl::-Wno-invalid-offsetof", + "clang_cl::-Wno-microsoft-include", "clang_cl::-Wno-overloaded-virtual", - "clang_cl::-Wno-reinterpret-base-class" + "clang_cl::-Wno-pragma-system-header-outside-header", + "clang_cl::-Wno-reinterpret-base-class", + "clang_cl::-Wno-switch", + "clang_cl::-Wno-unused-private-field", + { public = true } )