[swift-dev] Compiling on FreeBSD

Sangjin Han tinysun.net at gmail.com
Fri Sep 23 05:41:10 CDT 2016


Hi K,

I met similar problem in Cygwin porting.

I think it will be resolved by defining the typealias with #if/#endif,
_stdlib_pthread_attr_t
= UnsafePointer<pthread_attr_t?>.

Please reference my PR for Cygwin.
https://github.com/apple/swift/pull/3886/files#diff-99fd89ad44c4466de8ad6b8aab9c207d

Thanks
Han Sangjin

2016-09-19 5:08 GMT+09:00 K Staring via swift-dev <swift-dev at swift.org>:

> Hi,
>
> While trying to port the current swift code to FreeBSD, some swift code
> fails to compile. The failures are concentrated in
> SwiftPrivatePthreadExtras.swift and code which depends on it.
>
> Can someone shed some light on the following errors? I am having some
> difficulty understanding why the C headers would be interpreted so slightly
> differently than expected?
>
> --(start compile failure)
> /home/qdk/src/swift-source/swift/stdlib/private/SwiftPrivatePthreadExtras/
> SwiftPrivatePthreadExtras.swift:75:42: error: cannot convert value of
> type 'UnsafePointer<pthread_attr_t>?' to expected argument type
> 'UnsafePointer<pthread_attr_t?>!'
>   let result = pthread_create(&threadID, attr,
>                                          ^~~~
> /home/qdk/src/swift-source/swift/stdlib/private/SwiftPrivatePthreadExtras/PthreadBarriers.swift:72:46:
> error: cannot convert value of type 'UnsafeMutablePointer<pthread_mutex_t>'
> (aka 'UnsafeMutablePointer<OpaquePointer>') to expected argument type
> 'UnsafeMutablePointer<pthread_mutex_t?>' (aka 'UnsafeMutablePointer<
> Optional<OpaquePointer>>')
>   if pthread_mutex_init(barrier.pointee.mutex!, nil) != 0 {
>                         ~~~~~~~~~~~~~~~~~~~~~^
> /home/qdk/src/swift-source/swift/stdlib/private/SwiftPrivatePthreadExtras/PthreadBarriers.swift:77:44:
> error: cannot convert value of type 'UnsafeMutablePointer<pthread_cond_t>'
> (aka 'UnsafeMutablePointer<OpaquePointer>') to expected argument type
> 'UnsafeMutablePointer<pthread_cond_t?>' (aka 'UnsafeMutablePointer<
> Optional<OpaquePointer>>')
>   if pthread_cond_init(barrier.pointee.cond!, nil) != 0 {
>                        ~~~~~~~~~~~~~~~~~~~~^
>
> --(end compile failure)
>
> Thanks for any suggestions or pointers!
>
> --
> Kind regards,
>
> K Staring <qdk at quickdekay.net>
>
>
> _______________________________________________
> swift-dev mailing list
> swift-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20160923/a7a8996d/attachment.html>


More information about the swift-dev mailing list