From 92894a35b1fe44db301acbe7915181542527088a Mon Sep 17 00:00:00 2001 From: Carlo Bramini <30959007+carlo-bramini@users.noreply.github.com> Date: Sun, 12 Nov 2023 14:28:04 +0100 Subject: [PATCH] WIN32: fix declaration of UINT_PTR This code added a macro UINT_PTR but on W32API and MS PSDK it is declared with a typedef instead, see here: https://github.com/mingw-w32/mingw-org-wsl/blob/5ae20fb2ea2f986ba30174feafc6842f0e98fd14/w32api/include/basetsd.h#L64 https://github.com/mingw-w32/mingw-org-wsl/blob/5ae20fb2ea2f986ba30174feafc6842f0e98fd14/w32api/include/basetsd.h#L102 For this reason, it happened that: 1) UINT_PTR is always undefined, even when compiling for Windows on both MINGW and MSVC. 2) HAVE_UINTPTR_T is handled by autoconf configure script, but not by CMakeLists.txt. So, when compiling with CMake, HAVE_UINTPTR_T is always undefined. For this reasons, when compiling on 64bit for Windows, UINT_PTR was set to unsigned long, by overwriting the system type with this macro. In my opinion, the best way to avoid malfunctions and complains from MINGW and MSVC when compiling for 64bit is to not overload that system type with this macro. --- src/lo_types_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lo_types_internal.h b/src/lo_types_internal.h index ce0177f..bc7cd5d 100644 --- a/src/lo_types_internal.h +++ b/src/lo_types_internal.h @@ -30,7 +30,7 @@ typedef SSIZE_T ssize_t; #endif -#ifndef UINT_PTR +#if !defined(UINT_PTR) && !defined(WIN32) #ifdef HAVE_UINTPTR_T #include #define UINT_PTR uintptr_t