Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIN32: fix declaration of UINT_PTR #149

Merged
merged 1 commit into from
Dec 2, 2023

Conversation

carlo-bramini
Copy link
Contributor

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.

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.
@JohannesLorenz
Copy link
Collaborator

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

@JohannesLorenz JohannesLorenz merged commit cb078a0 into radarsat1:master Dec 2, 2023
2 of 3 checks passed
@carlo-bramini carlo-bramini deleted the fix_windows_5 branch December 3, 2023 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants