From 36535514d54096d77b7943a5ac282d79c8e57522 Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 11 Jan 2021 10:26:17 +0100 Subject: [PATCH] Backends: DX12: Fix warning (#3706). Disable obsolete Tables enums, leave them commented out. Using _MSVC_LANG to enable offsetof() and static_assert() on VS2015.3+ --- backends/imgui_impl_dx12.h | 10 ++++++++++ imgui.h | 8 ++++---- imgui_demo.cpp | 3 +++ imgui_internal.h | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/backends/imgui_impl_dx12.h b/backends/imgui_impl_dx12.h index c18bbea3..7051962a 100644 --- a/backends/imgui_impl_dx12.h +++ b/backends/imgui_impl_dx12.h @@ -16,6 +16,11 @@ #pragma once #include "imgui.h" // IMGUI_IMPL_API +#ifdef _MSC_VER +#pragma warning (push) +#pragma warning (disable: 4471) // a forward declaration of an unscoped enumeration must have an underlying type +#endif + enum DXGI_FORMAT; struct ID3D12Device; struct ID3D12DescriptorHeap; @@ -36,3 +41,8 @@ IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3 // Use if you want to reset your rendering device without losing Dear ImGui state. IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects(); IMGUI_IMPL_API bool ImGui_ImplDX12_CreateDeviceObjects(); + +#ifdef _MSC_VER +#pragma warning (pop) +#endif + diff --git a/imgui.h b/imgui.h index db3d1fd6..a94f58f2 100644 --- a/imgui.h +++ b/imgui.h @@ -59,7 +59,7 @@ Index of this file: // Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens) #define IMGUI_VERSION "1.80 WIP" -#define IMGUI_VERSION_NUM 17909 +#define IMGUI_VERSION_NUM 17910 #define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx)) #define IMGUI_HAS_TABLE @@ -80,7 +80,7 @@ Index of this file: #endif #define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR) / sizeof(*(_ARR)))) // Size of a static C-style array. Don't use on pointers! #define IM_UNUSED(_VAR) ((void)(_VAR)) // Used to silence "unused variable warnings". Often useful as asserts may be stripped out from final builds. -#if (__cplusplus >= 201100) +#if (__cplusplus >= 201100) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201100) #define IM_OFFSETOF(_TYPE,_MEMBER) offsetof(_TYPE, _MEMBER) // Offset of _MEMBER within _TYPE. Standardized as offsetof() in C++11 #else #define IM_OFFSETOF(_TYPE,_MEMBER) ((size_t)&(((_TYPE*)0)->_MEMBER)) // Offset of _MEMBER within _TYPE. Old style macro. @@ -1106,8 +1106,8 @@ enum ImGuiTableFlags_ // Obsolete names (will be removed soon) #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - , ImGuiTableFlags_ColumnsWidthFixed = ImGuiTableFlags_SizingFixedFit, ImGuiTableFlags_ColumnsWidthStretch = ImGuiTableFlags_SizingStretchSame // WIP Tables 2020/12 - , ImGuiTableFlags_SizingPolicyFixed = ImGuiTableFlags_SizingFixedFit, ImGuiTableFlags_SizingPolicyStretch = ImGuiTableFlags_SizingStretchSame // WIP Tables 2021/01 + //, ImGuiTableFlags_ColumnsWidthFixed = ImGuiTableFlags_SizingFixedFit, ImGuiTableFlags_ColumnsWidthStretch = ImGuiTableFlags_SizingStretchSame // WIP Tables 2020/12 + //, ImGuiTableFlags_SizingPolicyFixed = ImGuiTableFlags_SizingFixedFit, ImGuiTableFlags_SizingPolicyStretch = ImGuiTableFlags_SizingStretchSame // WIP Tables 2021/01 #endif }; diff --git a/imgui_demo.cpp b/imgui_demo.cpp index ff905015..dd29a605 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -5552,6 +5552,9 @@ void ImGui::ShowAboutWindow(bool* p_open) #ifdef _MSC_VER ImGui::Text("define: _MSC_VER=%d", _MSC_VER); #endif +#ifdef _MSVC_LANG + ImGui::Text("define: _MSVC_LANG=%d", (int)_MSVC_LANG); +#endif #ifdef __MINGW32__ ImGui::Text("define: __MINGW32__"); #endif diff --git a/imgui_internal.h b/imgui_internal.h index 29559a64..6e6be397 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -178,7 +178,7 @@ namespace ImStb #define IMGUI_DEBUG_LOG_NAV(...) ((void)0) // Disable log // Static Asserts -#if (__cplusplus >= 201100) +#if (__cplusplus >= 201100) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201100) #define IM_STATIC_ASSERT(_COND) static_assert(_COND, "") #else #define IM_STATIC_ASSERT(_COND) typedef char static_assertion_##__line__[(_COND)?1:-1]