From c55dfbf6568d17643ddc34f5facf25e3a90acdc9 Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Thu, 11 Dec 2025 10:48:00 -0500
Subject: [PATCH] StdIo: Restore compilation on 32-bit MinGW

In commit e419429616 (StdIo: Restore Windows Console I/O modes on
Ctrl-C, 2025-11-26, v4.1.4~4^2) we relied on the compiler to generate a
lambda with an `operator()` for each calling convention.  MSVC does
this, but the GNU compiler for MinGW does not seem to.
---
 Source/cmStdIoInit.cxx | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/Source/cmStdIoInit.cxx b/Source/cmStdIoInit.cxx
index a2fc50db7f3..49f31873bdc 100644
--- a/Source/cmStdIoInit.cxx
+++ b/Source/cmStdIoInit.cxx
@@ -93,19 +93,23 @@ public:
 
   Globals();
 
+#ifdef _WIN32
+  static BOOL WINAPI CtrlHandler(DWORD /*dwCtrlType*/)
+  {
+    Get().StdErr.Destroy();
+    Get().StdOut.Destroy();
+    Get().StdIn.Destroy();
+    return FALSE;
+  }
+#endif
+
   static Globals& Get();
 };
 
 #ifdef _WIN32
 Globals::Globals()
 {
-  static auto const ctrlHandler = [](DWORD /*dwCtrlType*/) -> BOOL {
-    Get().StdErr.Destroy();
-    Get().StdOut.Destroy();
-    Get().StdIn.Destroy();
-    return FALSE;
-  };
-  SetConsoleCtrlHandler(ctrlHandler, TRUE);
+  SetConsoleCtrlHandler(CtrlHandler, TRUE);
 }
 #else
 Globals::Globals() = default;
-- 
GitLab

