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 2641 - [Patch] Mac/iOS: SDL_SysWMinfo struct can't be created in ObjC files which use ARC
Summary: [Patch] Mac/iOS: SDL_SysWMinfo struct can't be created in ObjC files which us...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: x86 Mac OS X (All)
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-14 02:55 UTC by Alex Szpakowski
Modified: 2014-07-30 18:14 UTC (History)
1 user (show)

See Also:


Attachments
Fix for including SDL_syswm.h in ObjC files which use ARC (902 bytes, patch)
2014-07-14 02:55 UTC, Alex Szpakowski
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Szpakowski 2014-07-14 02:55:25 UTC
Created attachment 1753 [details]
Fix for including SDL_syswm.h in ObjC files which use ARC

In OS X and iOS, the SDL_SysWMinfo struct contains a struct which has an Objective-C object (an NSWindow or UIWindow for OS X or iOS respectively.)

When using Objective-C's Automatic Reference Counting mode in a file, Objective-C objects normally aren't allowed to be inside C structs or unions unless they're tagged with '__unsafe_unretained'.

The NSWindow and UIWindow objects in the SDL_SysWMinfo struct don't have that tag right now, which is a problem because an Objective-C file using ARC can include SDL_syswm.h but the compiler won't the struct be constructed in that file.

I have attached a patch which properly tags the objects in the struct with '__unsafe_unretained' when SDL_syswm.h is included in a file which uses Objective-C's ARC.
This shouldn't affect internal SDL behaviour at all, since none of its Objective-C code uses ARC (yet.)
Comment 1 Ryan C. Gordon 2014-07-30 18:14:58 UTC
This is now https://hg.libsdl.org/SDL/rev/d6464107048c, thanks!

--ryan.