We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3556

Summary: [WinRT, pointer truncation, Bug&fix] SDL_config.h(371): error C2371: 'uintptr_t': redefinition; different basic types
Product: SDL Reporter: Eugene Golushkov <eugene_gff>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: critical    
Priority: P2    
Version: 2.0.4   
Hardware: x86   
OS: Windows 10   

Description Eugene Golushkov 2017-01-11 14:20:01 UTC
SDL_config.h(371): error C2371: 'uintptr_t': redefinition; different basic types

uintptr_t is typedefed to unsigned long when SDL is built in WinRT mode, even in x64 builds where pointers are 64bit but longs are 32bit. That leads to either compilation error or even pointer truncation at runtime.

The reason is that both __WINDOWS__ and __WIN32__ are undefined when __WINRT__ is defined, and __WIN32__ is used to select MS or non-MS variant of typedef uintptr_t

Seems that proper fix for the issue is to change __WIN32__ definition

diff --git a/include/SDL_platform.h b/include/SDL_platform.h
--- a/include/SDL_platform.h
+++ b/include/SDL_platform.h
@@ -133,7 +133,7 @@
 #endif /* _MSC_VER < 1700 */
 #endif /* defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) */
 
-#if defined(__WINDOWS__)
+#if defined(__WINDOWS__) || defined(__WINRT__)
 #undef __WIN32__
 #define __WIN32__ 1
 #endif
Comment 1 Eugene Golushkov 2017-01-11 15:36:37 UTC
This problem is already fixed in v2.0.5 via separate SDL_config_winrt.h
Comment 2 Eugene Golushkov 2017-01-11 15:38:02 UTC
This problem is already fixed in v2.0.5 via separate SDL_config_winrt.h