From 0a95338a6a1e1c3d76f670981951b1b2e5caaf8b Mon Sep 17 00:00:00 2001 From: Christoph Wagner Date: Fri, 30 Jan 2026 10:02:23 +0100 Subject: [PATCH 1/2] define 'NOMINMAX' whenever 'windows.h' is included --- elf/portable_endian.h | 2 +- picoboot_connection/picoboot_connection.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/elf/portable_endian.h b/elf/portable_endian.h index 347dd50f..9db382aa 100644 --- a/elf/portable_endian.h +++ b/elf/portable_endian.h @@ -61,7 +61,7 @@ #endif #elif defined(__WINDOWS__) - +# define NOMINMAX # include # ifdef __GNUC__ # include diff --git a/picoboot_connection/picoboot_connection.h b/picoboot_connection/picoboot_connection.h index 2009b778..1b86da85 100644 --- a/picoboot_connection/picoboot_connection.h +++ b/picoboot_connection/picoboot_connection.h @@ -11,6 +11,9 @@ #include #if HAS_LIBUSB +#ifdef _WIN32 +#define NOMINMAX +#endif #include #endif #include "boot/picoboot.h" From 9730045b0d8e45d8ded6b7b3dfde5db30fd6dd34 Mon Sep 17 00:00:00 2001 From: Christoph Wagner Date: Fri, 30 Jan 2026 10:06:46 +0100 Subject: [PATCH 2/2] cleanup & remove now obsolete undefs --- elf/elf_file.cpp | 4 ---- main.cpp | 14 -------------- picoboot_connection/picoboot_connection_cxx.cpp | 3 --- 3 files changed, 21 deletions(-) diff --git a/elf/elf_file.cpp b/elf/elf_file.cpp index 52480440..0aa37e3a 100644 --- a/elf/elf_file.cpp +++ b/elf/elf_file.cpp @@ -23,11 +23,7 @@ #include "portable_endian.h" -// tsk namespace is polluted on windows #ifdef _WIN32 -#undef min -#undef max - #define _CRT_SECURE_NO_WARNINGS #endif diff --git a/main.cpp b/main.cpp index 917c4158..cd8308e2 100644 --- a/main.cpp +++ b/main.cpp @@ -69,13 +69,6 @@ static __forceinline int __builtin_ctz(unsigned x) { } #endif -// tsk namespace is polluted on windows -#ifdef _WIN32 -#undef min -#undef max - -#define _CRT_SECURE_NO_WARNINGS -#endif #define MAX_REBOOT_TRIES 5 @@ -8601,13 +8594,6 @@ bool reboot_command::execute(device_map &devices) { #include #endif -// tsk namespace is polluted on windows -#ifdef _WIN32 -#undef min -#undef max - -#define _CRT_SECURE_NO_WARNINGS -#endif static void sleep_ms(int ms) { #if defined(__unix__) || defined(__APPLE__) diff --git a/picoboot_connection/picoboot_connection_cxx.cpp b/picoboot_connection/picoboot_connection_cxx.cpp index f93e0a30..e4e0226f 100644 --- a/picoboot_connection/picoboot_connection_cxx.cpp +++ b/picoboot_connection/picoboot_connection_cxx.cpp @@ -11,9 +11,6 @@ #include "picoboot_connection_cxx.h" #ifdef _WIN32 -#undef min -#undef max - #define _CRT_SECURE_NO_WARNINGS #endif