diff --git a/CMakeLists.txt b/CMakeLists.txt index 122a66f8..9ff1e161 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -494,7 +494,7 @@ if(MSVC) if(NO_WCHAR_T) message(STATUS "Using non-native wchar_t as unsigned short") - target_compile_options(${PROJECT_NAME} PRIVATE "/Zc:wchar_t-") + target_compile_options(${PROJECT_NAME} PRIVATE /Zc:wchar_t-) endif() endif() @@ -505,14 +505,14 @@ target_link_options(${PROJECT_NAME} PRIVATE ${LINKER_SWITCHES}) 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}) elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") - target_compile_options(${PROJECT_NAME} PRIVATE "-Wno-ignored-attributes" "-Walloc-size-larger-than=4GB") + target_compile_options(${PROJECT_NAME} PRIVATE -Wno-ignored-attributes -Walloc-size-larger-than=4GB) if(BUILD_SHARED_LIBS) - target_compile_options(${PROJECT_NAME} PRIVATE "-Wno-attributes") + target_compile_options(${PROJECT_NAME} PRIVATE -Wno-attributes) endif() elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") if(BUILD_SHARED_LIBS) 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 02c5ea30..ba91e038 100644 --- a/Src/pch.h +++ b/Src/pch.h @@ -78,6 +78,7 @@ #pragma clang diagnostic ignored "-Wlanguage-extension-token" #pragma clang diagnostic ignored "-Wmissing-variable-declarations" #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"