radarsat1 / liblo

liblo is an implementation of the Open Sound Control protocol for POSIX systems
GNU Lesser General Public License v2.1
192 stars 60 forks source link

WIN32: fix declaration of UINT_PTR #149

Closed carlo-bramini closed 11 months ago

carlo-bramini commented 1 year ago

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 because it's a typedef, 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 also 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 when WIN32 is defined.

JohannesLorenz commented 11 months ago

Makes sense. It still compiles without that definition, so it got UINT_PTR from the Windows headers. LGTM.