Browse Source

Fix various warnings (#4442)

pull/4472/head
ocornut 3 years ago
parent
commit
f24abbc47d
  1. 1
      backends/imgui_impl_opengl3.cpp
  2. 10
      backends/imgui_impl_sdl.cpp
  3. 24
      examples/example_emscripten_opengl3/Makefile
  4. 23
      examples/example_emscripten_wgpu/Makefile
  5. 8
      examples/example_null/Makefile
  6. 11
      imgui_internal.h

1
backends/imgui_impl_opengl3.cpp

@ -531,6 +531,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
#endif #endif
glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]); glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]); glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
(void)bd; // Not all compilation paths use this
} }
bool ImGui_ImplOpenGL3_CreateFontsTexture() bool ImGui_ImplOpenGL3_CreateFontsTexture()

10
backends/imgui_impl_sdl.cpp

@ -60,7 +60,11 @@
#include "TargetConditionals.h" #include "TargetConditionals.h"
#endif #endif
#define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE (SDL_VERSION_ATLEAST(2,0,4) && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IOS)) #if SDL_VERSION_ATLEAST(2,0,4) && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IOS)
#define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE 1
#else
#define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE 0
#endif
#define SDL_HAS_MOUSE_FOCUS_CLICKTHROUGH SDL_VERSION_ATLEAST(2,0,5) #define SDL_HAS_MOUSE_FOCUS_CLICKTHROUGH SDL_VERSION_ATLEAST(2,0,5)
#define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6) #define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6)
@ -168,10 +172,10 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window)
// Check and store if we are on a SDL backend that supports global mouse position // Check and store if we are on a SDL backend that supports global mouse position
// ("wayland" and "rpi" don't support it, but we chose to use a white-list instead of a black-list) // ("wayland" and "rpi" don't support it, but we chose to use a white-list instead of a black-list)
const char* sdl_backend = SDL_GetCurrentVideoDriver();
const char* global_mouse_whitelist[] = { "windows", "cocoa", "x11", "DIVE", "VMAN" };
bool mouse_can_use_global_state = false; bool mouse_can_use_global_state = false;
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE #if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE
const char* sdl_backend = SDL_GetCurrentVideoDriver();
const char* global_mouse_whitelist[] = { "windows", "cocoa", "x11", "DIVE", "VMAN" };
for (int n = 0; n < IM_ARRAYSIZE(global_mouse_whitelist); n++) for (int n = 0; n < IM_ARRAYSIZE(global_mouse_whitelist); n++)
if (strncmp(sdl_backend, global_mouse_whitelist[n], strlen(global_mouse_whitelist[n])) == 0) if (strncmp(sdl_backend, global_mouse_whitelist[n], strlen(global_mouse_whitelist[n])) == 0)
mouse_can_use_global_state = true; mouse_can_use_global_state = true;

24
examples/example_emscripten_opengl3/Makefile

@ -23,15 +23,18 @@ SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui
SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
UNAME_S := $(shell uname -s) UNAME_S := $(shell uname -s)
CPPFLAGS =
LDFLAGS =
EMS =
##--------------------------------------------------------------------- ##---------------------------------------------------------------------
## EMSCRIPTEN OPTIONS ## EMSCRIPTEN OPTIONS
##--------------------------------------------------------------------- ##---------------------------------------------------------------------
EMS += -s USE_SDL=2 -s WASM=1 # ("EMS" options gets added to both CPPFLAGS and LDFLAGS, whereas some options are for linker only)
EMS += -s ALLOW_MEMORY_GROWTH=1 EMS += -s USE_SDL=2
EMS += -s DISABLE_EXCEPTION_CATCHING=1 -s NO_EXIT_RUNTIME=0 EMS += -s DISABLE_EXCEPTION_CATCHING=1
EMS += -s ASSERTIONS=1 LDFLAGS += -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=0 -s ASSERTIONS=1
# Uncomment next line to fix possible rendering bugs with Emscripten version older then 1.39.0 (https://github.com/ocornut/imgui/issues/2877) # Uncomment next line to fix possible rendering bugs with Emscripten version older then 1.39.0 (https://github.com/ocornut/imgui/issues/2877)
#EMS += -s BINARYEN_TRAP_MODE=clamp #EMS += -s BINARYEN_TRAP_MODE=clamp
@ -43,7 +46,8 @@ EMS += -s ASSERTIONS=1
# (Default value is 0. Set to 1 to enable file-system and include the misc/fonts/ folder as part of the build.) # (Default value is 0. Set to 1 to enable file-system and include the misc/fonts/ folder as part of the build.)
USE_FILE_SYSTEM ?= 0 USE_FILE_SYSTEM ?= 0
ifeq ($(USE_FILE_SYSTEM), 0) ifeq ($(USE_FILE_SYSTEM), 0)
EMS += -s NO_FILESYSTEM=1 -DIMGUI_DISABLE_FILE_FUNCTIONS LDFLAGS += -s NO_FILESYSTEM=1
CPPFLAGS += -DIMGUI_DISABLE_FILE_FUNCTIONS
endif endif
ifeq ($(USE_FILE_SYSTEM), 1) ifeq ($(USE_FILE_SYSTEM), 1)
LDFLAGS += --no-heap-copy --preload-file ../../misc/fonts@/fonts LDFLAGS += --no-heap-copy --preload-file ../../misc/fonts@/fonts
@ -53,12 +57,10 @@ endif
## FINAL BUILD FLAGS ## FINAL BUILD FLAGS
##--------------------------------------------------------------------- ##---------------------------------------------------------------------
CPPFLAGS = -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends CPPFLAGS += -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends
#CPPFLAGS += -g #CPPFLAGS += -g
CPPFLAGS += -Wall -Wformat -Os CPPFLAGS += -Wall -Wformat -Os $(EMS)
CPPFLAGS += $(EMS) LDFLAGS += --shell-file shell_minimal.html $(EMS)
LIBS += $(EMS)
LDFLAGS += --shell-file shell_minimal.html
##--------------------------------------------------------------------- ##---------------------------------------------------------------------
## BUILD RULES ## BUILD RULES
@ -86,7 +88,7 @@ serve: all
python3 -m http.server -d $(WEB_DIR) python3 -m http.server -d $(WEB_DIR)
$(EXE): $(OBJS) $(WEB_DIR) $(EXE): $(OBJS) $(WEB_DIR)
$(CXX) -o $@ $(OBJS) $(LIBS) $(LDFLAGS) $(CXX) -o $@ $(OBJS) $(LDFLAGS)
clean: clean:
rm -rf $(OBJS) $(WEB_DIR) rm -rf $(OBJS) $(WEB_DIR)

23
examples/example_emscripten_wgpu/Makefile

@ -23,15 +23,18 @@ SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui
SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glfw.cpp $(IMGUI_DIR)/backends/imgui_impl_wgpu.cpp SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glfw.cpp $(IMGUI_DIR)/backends/imgui_impl_wgpu.cpp
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
UNAME_S := $(shell uname -s) UNAME_S := $(shell uname -s)
CPPFLAGS =
LDFLAGS =
EMS =
##--------------------------------------------------------------------- ##---------------------------------------------------------------------
## EMSCRIPTEN OPTIONS ## EMSCRIPTEN OPTIONS
##--------------------------------------------------------------------- ##---------------------------------------------------------------------
EMS += -s USE_GLFW=3 -s USE_WEBGPU=1 -s WASM=1 # ("EMS" options gets added to both CPPFLAGS and LDFLAGS, whereas some options are for linker only)
EMS += -s ALLOW_MEMORY_GROWTH=1 EMS += -s DISABLE_EXCEPTION_CATCHING=1
EMS += -s DISABLE_EXCEPTION_CATCHING=1 -s NO_EXIT_RUNTIME=0 LDFLAGS += -s USE_GLFW=3 -s USE_WEBGPU=1
EMS += -s ASSERTIONS=1 LDFLAGS += -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=0 -s ASSERTIONS=1
# Emscripten allows preloading a file or folder to be accessible at runtime. # Emscripten allows preloading a file or folder to be accessible at runtime.
# The Makefile for this example project suggests embedding the misc/fonts/ folder into our application, it will then be accessible as "/fonts" # The Makefile for this example project suggests embedding the misc/fonts/ folder into our application, it will then be accessible as "/fonts"
@ -39,7 +42,8 @@ EMS += -s ASSERTIONS=1
# (Default value is 0. Set to 1 to enable file-system and include the misc/fonts/ folder as part of the build.) # (Default value is 0. Set to 1 to enable file-system and include the misc/fonts/ folder as part of the build.)
USE_FILE_SYSTEM ?= 0 USE_FILE_SYSTEM ?= 0
ifeq ($(USE_FILE_SYSTEM), 0) ifeq ($(USE_FILE_SYSTEM), 0)
EMS += -s NO_FILESYSTEM=1 -DIMGUI_DISABLE_FILE_FUNCTIONS LDFLAGS += -s NO_FILESYSTEM=1
CPPFLAGS += -DIMGUI_DISABLE_FILE_FUNCTIONS
endif endif
ifeq ($(USE_FILE_SYSTEM), 1) ifeq ($(USE_FILE_SYSTEM), 1)
LDFLAGS += --no-heap-copy --preload-file ../../misc/fonts@/fonts LDFLAGS += --no-heap-copy --preload-file ../../misc/fonts@/fonts
@ -49,12 +53,11 @@ endif
## FINAL BUILD FLAGS ## FINAL BUILD FLAGS
##--------------------------------------------------------------------- ##---------------------------------------------------------------------
CPPFLAGS = -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends CPPFLAGS += -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends
#CPPFLAGS += -g #CPPFLAGS += -g
CPPFLAGS += -Wall -Wformat -Os CPPFLAGS += -Wall -Wformat -Os $(EMS)
CPPFLAGS += $(EMS)
LIBS += $(EMS)
#LDFLAGS += --shell-file shell_minimal.html #LDFLAGS += --shell-file shell_minimal.html
LDFLAGS += $(EMS)
##--------------------------------------------------------------------- ##---------------------------------------------------------------------
## BUILD RULES ## BUILD RULES
@ -79,7 +82,7 @@ serve: all
python3 -m http.server -d $(WEB_DIR) python3 -m http.server -d $(WEB_DIR)
$(EXE): $(OBJS) $(WEB_DIR) $(EXE): $(OBJS) $(WEB_DIR)
$(CXX) -o $@ $(OBJS) $(LIBS) $(LDFLAGS) $(CXX) -o $@ $(OBJS) $(LDFLAGS)
clean: clean:
rm -f $(EXE) $(OBJS) $(WEB_DIR)/*.js $(WEB_DIR)/*.wasm $(WEB_DIR)/*.wasm.pre rm -f $(EXE) $(OBJS) $(WEB_DIR)/*.js $(WEB_DIR)/*.wasm $(WEB_DIR)/*.wasm.pre

8
examples/example_null/Makefile

@ -40,7 +40,7 @@ endif
ifeq ($(UNAME_S), Linux) #LINUX ifeq ($(UNAME_S), Linux) #LINUX
ECHO_MESSAGE = "Linux" ECHO_MESSAGE = "Linux"
ifneq ($(WITH_EXTRA_WARNINGS), 0) ifeq ($(WITH_EXTRA_WARNINGS), 1)
CXXFLAGS += -Wextra -Wpedantic CXXFLAGS += -Wextra -Wpedantic
ifeq ($(shell $(CXX) -v 2>&1 | grep -c "clang version"), 1) ifeq ($(shell $(CXX) -v 2>&1 | grep -c "clang version"), 1)
CXXFLAGS += -Wshadow -Wsign-conversion CXXFLAGS += -Wshadow -Wsign-conversion
@ -51,15 +51,15 @@ endif
ifeq ($(UNAME_S), Darwin) #APPLE ifeq ($(UNAME_S), Darwin) #APPLE
ECHO_MESSAGE = "Mac OS X" ECHO_MESSAGE = "Mac OS X"
ifneq ($(WITH_EXTRA_WARNINGS), 0) ifeq ($(WITH_EXTRA_WARNINGS), 1)
CXXFLAGS += -Weverything -Wno-reserved-id-macro -Wno-c++98-compat-pedantic -Wno-padded -Wno-c++11-long-long CXXFLAGS += -Weverything -Wno-reserved-id-macro -Wno-c++98-compat-pedantic -Wno-padded -Wno-c++11-long-long -Wno-poison-system-directories
endif endif
CFLAGS = $(CXXFLAGS) CFLAGS = $(CXXFLAGS)
endif endif
ifeq ($(OS), Windows_NT) ifeq ($(OS), Windows_NT)
ECHO_MESSAGE = "MinGW" ECHO_MESSAGE = "MinGW"
ifneq ($(WITH_EXTRA_WARNINGS), 0) ifeq ($(WITH_EXTRA_WARNINGS), 1)
CXXFLAGS += -Wextra -Wpedantic CXXFLAGS += -Wextra -Wpedantic
endif endif
LIBS += -limm32 LIBS += -limm32

11
imgui_internal.h

@ -88,6 +88,13 @@ Index of this file:
#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead #pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
#endif #endif
// Helper macros
#if defined(__clang__)
#define IM_NORETURN __attribute__((noreturn))
#else
#define IM_NORETURN
#endif
// Legacy defines // Legacy defines
#ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS // Renamed in 1.74 #ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS // Renamed in 1.74
#error Use IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS #error Use IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
@ -2421,8 +2428,8 @@ namespace ImGui
// (Old) IMGUI_VERSION_NUM < 18209: using 'ItemAdd(....)' and 'bool focused = FocusableItemRegister(...)' // (Old) IMGUI_VERSION_NUM < 18209: using 'ItemAdd(....)' and 'bool focused = FocusableItemRegister(...)'
// (New) IMGUI_VERSION_NUM >= 18209: using 'ItemAdd(..., ImGuiItemAddFlags_Focusable)' and 'bool focused = (GetItemStatusFlags() & ImGuiItemStatusFlags_Focused) != 0' // (New) IMGUI_VERSION_NUM >= 18209: using 'ItemAdd(..., ImGuiItemAddFlags_Focusable)' and 'bool focused = (GetItemStatusFlags() & ImGuiItemStatusFlags_Focused) != 0'
// Widget code are simplified as there's no need to call FocusableItemUnregister() while managing the transition from regular widget to TempInputText() // Widget code are simplified as there's no need to call FocusableItemUnregister() while managing the transition from regular widget to TempInputText()
inline bool FocusableItemRegister(ImGuiWindow* window, ImGuiID id) { IM_ASSERT(0); IM_UNUSED(window); IM_UNUSED(id); return false; } // -> pass ImGuiItemAddFlags_Focusable flag to ItemAdd() inline bool FocusableItemRegister(ImGuiWindow* window, ImGuiID id) { IM_ASSERT(0); IM_UNUSED(window); IM_UNUSED(id); return false; } // -> pass ImGuiItemAddFlags_Focusable flag to ItemAdd()
inline void FocusableItemUnregister(ImGuiWindow* window) { IM_ASSERT(0); IM_UNUSED(window); } // -> unnecessary: TempInputText() uses ImGuiInputTextFlags_MergedItem inline IM_NORETURN void FocusableItemUnregister(ImGuiWindow* window) { IM_ASSERT(0); IM_UNUSED(window); } // -> unnecessary: TempInputText() uses ImGuiInputTextFlags_MergedItem
#endif #endif
// Logging/Capture // Logging/Capture

Loading…
Cancel
Save