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 1816 - Future-Proofing for WinRT and C++/CX: SDL_event.h may fail to compile in future ports of SDL
Summary: Future-Proofing for WinRT and C++/CX: SDL_event.h may fail to compile in futu...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: HG 2.0
Hardware: Other Other
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-20 23:24 UTC by David Ludwig
Modified: 2013-04-21 14:54 UTC (History)
1 user (show)

See Also:


Attachments
renames SDL_Event's "generic" field to "common", for future C++/CX compatibility (1.50 KB, application/octet-stream)
2013-04-20 23:24 UTC, David Ludwig
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Ludwig 2013-04-20 23:24:47 UTC
Created attachment 1120 [details]
renames SDL_Event's "generic" field to "common", for future C++/CX compatibility

Hi,

I just wanted to give you all a heads-up regarding a possible incompatibility for any future versions of SDL that support WinRT, or one of the platforms it is based on.  I've been doing work on an unofficial port of SDL 2.x to WinRT (at http://bitbucket.org/davidludwig/sdl), and found a bug that, if SDL were ever to support WinRT, or one of the platforms it is based on (Windows Phone 8 being one), it may prevent SDL's public headers from being compiled without hacks.  The issue was found while doing a merge of my own fork (of SDL 2.x) with the latest code from hg.libsdl.org/SDL.

The issue is that a recent commit, http://hg.libsdl.org/SDL/rev/4de584a3a027, added a field to SDL_Event, "generic", which can cause SDL_event.h to not be compile-able.  The word "generic" is reserved in a new, Microsoft-specific, C++ extension called C++/CX, which is used to help build WinRT components.  More info on the keyword is available at http://msdn.microsoft.com/en-us/library/windows/apps/hh755792.aspx.  The C++/CX extension is optional for WinRT development, and can be turned off to allow SDL_event.h to compile.  Much of Microsoft's sample code and documentation for WinRT, however, does use the extension.

It is possible to work around the problem, however there are drawbacks.  Macros can be used to redefine 'generic', however this could make it difficult to use SDL_Event's new filed in C++/CX enabled code, in a cross-platform manner.  C++/CX can be disabled, however this would prevent much of Microsoft's sample code for WinRT from being used in the same files that use SDL, or at least make it difficult.

In case modifying SDL 2.x is an option, I've attached one possible patch that renames SDL_Event's "generic" field to "common".  The patch was not made against my own tree, and instead was made against an up-to-date copy of the official SDL 2.x HG sources (as of the changeset, http://hg.libsdl.org/SDL/rev/ab543a0ef80c).

This is the only language-level incompatibility I've seen so far (in compiling SDL's public headers with C++/CX).  I have run into a fair amount of other incompatibilities involved with porting SDL to WinRT, however most of those have been API related.  This is the only bug I've seen so far that has required any sort of change to the SDL public API.

Cheers, and good luck with the SDL 2.x update!
Comment 1 David Ludwig 2013-04-21 00:26:57 UTC
One additional, and somewhat unrelated note and correction: on the topic of porting SDL to WinRT, a few other changes do seem to be warranted to SDL's public API in order to get it running on WinRT.  I mentioned that the issue described in this bugzilla-entry was the only one warranting some kind of change to SDL's public API, however this has not entirely been the case, at least in my experience.  Instead, this patch is the only WinRT-specific change to SDL's headers that, AFAIK, explicitly breaks a cross-platform portion of SDL's API.  Other changes do seem to be required to SDL's public headers, such as changes to SDL_config.h and SDL_platform.h, however they are non-API-breaking, and as such, beyond the scope of this bugzilla-entry.
Comment 2 Sam Lantinga 2013-04-21 14:54:09 UTC
Fixed, thanks!
http://hg.libsdl.org/SDL/rev/e9d6004d2978