[swift-dev] UnsafeMutablePointer.init()

Joe Groff jgroff at apple.com
Fri Feb 19 15:21:13 CST 2016


> On Feb 19, 2016, at 1:03 PM, Guillaume Lessard via swift-dev <swift-dev at swift.org> wrote:
> 
> In the currently planned version of the future, UnsafeMutablePointer loses its no-parameter initializer. I saw this as unnecessary, but it didn’t raise a red flag for me until trying to initialize a pthread_t in cross-platform code.
> 
> On Darwin, pthread_t maps to UnsafeMutablePointer:
> public typealias pthread_t = __darwin_pthread_t
> public typealias __darwin_pthread_t = UnsafeMutablePointer<_opaque_pthread_t>
> 
> On Linux, it does not (from /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h):
> typedef unsigned long int pthread_t;
> 
> As a result, there is no longer an initializer that works in both cases without generating a deprecation warning.
> 
> 
> Is the solution to fix this with new import overlays, or to reinstate UnsafeMutablePointer.init() ?

Improving the overlay seems to me like the right thing to do.

-Joe


More information about the swift-dev mailing list