diff --git a/CMakeLists.txt b/CMakeLists.txt index d97b3ebe..141347a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -463,7 +463,7 @@ if(MSVC) if(NO_WCHAR_T) message(STATUS "Using non-native wchar_t as unsigned short") foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) - target_compile_options(${t} PRIVATE "/Zc:wchar_t-") + target_compile_options(${t} PRIVATE /Zc:wchar_t-) endforeach() endif() endif() @@ -477,13 +477,14 @@ endforeach() if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|IntelLLVM") set(WarningsLib -Wall -Wpedantic -Wextra) if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0) - list(APPEND WarningsLib "-Wno-unsafe-buffer-usage") + list(APPEND WarningsLib -Wno-unsafe-buffer-usage) endif() target_compile_options(${PROJECT_NAME} PRIVATE ${WarningsLib}) - set(WarningsEXE ${WarningsLib} "-Wno-c++98-compat" "-Wno-c++98-compat-pedantic" "-Wno-switch-default" - "-Wno-double-promotion" "-Wno-exit-time-destructors" "-Wno-gnu-anonymous-struct" - "-Wno-missing-prototypes" "-Wno-nested-anon-types" "-Wno-unused-const-variable") + set(WarningsEXE ${WarningsLib} + -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-switch-default + -Wno-double-promotion -Wno-exit-time-destructors -Wno-gnu-anonymous-struct + -Wno-missing-prototypes -Wno-nested-anon-types -Wno-unused-const-variable -Wno-padded) foreach(t IN LISTS TOOL_EXES) target_compile_options(${t} PRIVATE ${WarningsEXE}) endforeach() diff --git a/Src/PlatformHelpers.h b/Src/PlatformHelpers.h index 2d163675..d1696ce3 100644 --- a/Src/PlatformHelpers.h +++ b/Src/PlatformHelpers.h @@ -17,6 +17,7 @@ #include #include #include +#include #ifndef MAKEFOURCC #define MAKEFOURCC(ch0, ch1, ch2, ch3) \ @@ -41,19 +42,23 @@ namespace DirectX class com_exception : public std::exception { public: - com_exception(HRESULT hr) noexcept : result(hr) {} + explicit com_exception(HRESULT hr) : result(hr) + { + char str[64] = {}; + sprintf_s(str, "Failure with HRESULT of %08X", static_cast(result)); + message = str; + } const char* what() const noexcept override { - static char s_str[64] = {}; - sprintf_s(s_str, "Failure with HRESULT of %08X", static_cast(result)); - return s_str; + return message.c_str(); } HRESULT get_result() const noexcept { return result; } private: HRESULT result; + std::string message; }; // Helper utility converts D3D API failures into exceptions. diff --git a/Src/pch.h b/Src/pch.h index 87a3995e..6db38093 100644 --- a/Src/pch.h +++ b/Src/pch.h @@ -77,6 +77,7 @@ #pragma clang diagnostic ignored "-Wmissing-variable-declarations" #pragma clang diagnostic ignored "-Wmicrosoft-include" #pragma clang diagnostic ignored "-Wnested-anon-types" +#pragma clang diagnostic ignored "-Wpadded" #pragma clang diagnostic ignored "-Wreserved-id-macro" #pragma clang diagnostic ignored "-Wswitch-enum" #pragma clang diagnostic ignored "-Wunknown-pragmas"