glessard
(Guillaume Lessard)
1
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() ?
Cheers,
Guillaume Lessard
Joe_Groff
(Joe Groff)
2
Improving the overlay seems to me like the right thing to do.
-Joe
···
On Feb 19, 2016, at 1:03 PM, Guillaume Lessard via swift-dev <swift-dev@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() ?
dabrahams
(Dave Abrahams)
3
I am not sure about whether we want UnsafeMutablePointer.init() in the
stdlib, but...
What about just extending UnsafeMutablePointer with your own init()?
···
on Fri Feb 19 2016, Guillaume Lessard <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() ?
--
-Dave