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 - [WinRT, pointer truncation, Bug&fix] SDL_config.h(371): error C2371: 'uintptr_t': redefinition; different basic types
Summary: [WinRT, pointer truncation, Bug&fix] SDL_config.h(371): error C2371: 'uintptr...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: 2.0.4
Hardware: x86 Windows 10
: P2 critical
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-11 14:20 UTC by Eugene Golushkov
Modified: 2017-01-11 15:38 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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