[swift-users] Casting function pointers

Rien Rien at Balancingrock.nl
Wed Jan 25 03:28:42 CST 2017


I should clarify: is it possible to cast:

> @convention(c) (_ ssl: OpaquePointer?, _ num: UnsafeMutablePointer<Int32>?, _ arg: UnsafeMutableRawPointer?) -> Int32

to:

> (() -> Void)!


???

Regards,
Rien

Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Balancingrock
Project: http://swiftfire.nl





> On 25 Jan 2017, at 10:23, Rien via swift-users <swift-users at swift.org> wrote:
> 
> I have a case where a callback has the following signature:
> 
> @convention(c) (_ ssl: OpaquePointer?, _ num: UnsafeMutablePointer<Int32>?, _ arg: UnsafeMutableRawPointer?) -> Int32
> 
> But to install this callback I have to use a c-function with this signature:
> 
> SSL_CTX_callback_ctrl (OpaquePointer!, Int32, (() -> Void)! )
> 
> Is it possible to cast the first function to the second? If so, how?
> 
> 
> 
> Regards,
> Rien
> 
> Site: http://balancingrock.nl
> Blog: http://swiftrien.blogspot.com
> Github: http://github.com/Balancingrock
> Project: http://swiftfire.nl
> 
> 
> 
> 
> 
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users



More information about the swift-users mailing list