From aa7d1e0905514ff173c401fcf5899983731bd40c Mon Sep 17 00:00:00 2001 From: Pascal Thomet Date: Wed, 29 Nov 2023 19:52:36 +0100 Subject: [PATCH] Correct WinMain issues with SDL --- src/hello_imgui/CMakeLists.txt | 3 +++ src/hello_imgui/hello_imgui.h | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/hello_imgui/CMakeLists.txt b/src/hello_imgui/CMakeLists.txt index e16e5b66..9f3d12e3 100644 --- a/src/hello_imgui/CMakeLists.txt +++ b/src/hello_imgui/CMakeLists.txt @@ -178,6 +178,9 @@ endif() if (IOS OR (MACOSX AND NOT HELLOIMGUI_MACOS_NO_BUNDLE)) target_compile_definitions(${target_name} PUBLIC HELLOIMGUI_INSIDE_APPLE_BUNDLE) endif() +if (HELLOIMGUI_WIN32_AUTO_WINMAIN) + target_compile_definitions(${target_name} PUBLIC HELLOIMGUI_WIN32_AUTO_WINMAIN) +endif() # install if (PROJECT_IS_TOP_LEVEL AND NOT IOS AND NOT ANDROID) diff --git a/src/hello_imgui/hello_imgui.h b/src/hello_imgui/hello_imgui.h index 393b4340..e5f7242e 100644 --- a/src/hello_imgui/hello_imgui.h +++ b/src/hello_imgui/hello_imgui.h @@ -14,7 +14,14 @@ #include #ifdef HELLOIMGUI_USE_SDL_OPENGL3 -#include // So that SDL can surreptitiously define its own main... + // Let SDL redefine main under iOS and co., but not under Windows, where we redefine WinMain + #ifdef _WIN32 + #ifndef HELLOIMGUI_WIN32_AUTO_WINMAIN + #include + #endif + #else + #include + #endif #endif struct ImGuiTestEngine;