<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 28, 2016, at 10:03 AM, John Brownie via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); float: none; display: inline !important;" class="">Thanks for the pointers. Good reading, but I'm still confused. I think that the first issue is clear to me now, but I don't know what I have to do to make the closure be seen as satisfying the type of the function pointer. It worked in Swift 2.2 as</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); float: none; display: inline !important;" class="">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; XML_SetEndElementHandler(parser) { (userData: UnsafeMutablePointer&lt;Void&gt;, name: UnsafePointer&lt;XML_Char&gt;) -&gt; Void in</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""></span><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); float: none; display: inline !important;" class="">All that's changed is making the UnsafeMutablePointer&lt;Void&gt; into UnsafeMutableRawPointer, unless it's the unwrapped nature of the parameter in the error message:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); float: none; display: inline !important;" class="">Cannot convert value of type '(UnsafeMutableRawPointer, UnsafePointer&lt;XML_Char&gt;) -&gt; Void' to expected argument type 'XML_EndElementHandler!'<span class="Apple-converted-space">&nbsp;</span></span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); float: none; display: inline !important;" class="">I don't know what I need to do next. Any help is much appreciated.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""></div></blockquote><div><br class=""></div><div><br class=""></div>Could you share the generated interface for these functions, so that we can see how they are being imported into Swift? Also, do you know exactly what version of the Swift compiler you’re using (I ask because there have been recent improvements in error messages)?<br class=""><blockquote type="cite" class=""><div class=""><blockquote cite="mid:63E963C6-70EB-4F57-9A2B-8FFFE856FAB4@apple.com" type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); border: 0px none;" class=""><div class="__pbConvHr" style="margin: 30px 25px 10px;"><div style="width: 1236px; border-top-width: 2px; border-top-style: solid; border-top-color: rgb(237, 241, 244); padding-top: 10px;" class=""><div style="display: inline-block; white-space: nowrap; vertical-align: middle; width: 605.625px;" class=""><a moz-do-not-send="true" href="mailto:swift-users@swift.org" style="padding-right: 6px; font-weight: 500; color: rgb(72, 86, 100) !important; text-decoration: none !important;" class="">Quinn "The Eskimo!" via swift-users</a></div><span class="Apple-converted-space">&nbsp;</span> <div style="display: inline-block; white-space: nowrap; vertical-align: middle; width: 593.265625px; text-align: right;" class=""><font color="#909AA4" class=""><span style="padding-left: 6px;" class="">28 September 2016 at 11:26</span></font></div></div></div><div __pbrmquotes="true" class="__pbConvBody" style="color: rgb(144, 154, 164); margin-left: 24px; margin-right: 24px;"><div class=""><br class="">I recommend reading the whole “Migrating to Swift 2.3 or Swift 3 from Swift 2.2” doc, but for this specific issue you should start with the “UnsafeRawPointer Migration” doc that it links to.<br class=""><br class=""><a class="moz-txt-link-rfc2396E" href="https://swift.org/migration-guide/">&lt;https://swift.org/migration-guide/&gt;</a><br class=""><br class=""><a class="moz-txt-link-rfc2396E" href="https://swift.org/migration-guide/se-0107-migrate.html">&lt;https://swift.org/migration-guide/se-0107-migrate.html&gt;</a><br class=""><br class="">Share and Enjoy<br class="">--<br class="">Quinn "The Eskimo!"<span class="Apple-converted-space">&nbsp;</span><span class="Apple-converted-space">&nbsp;</span><a class="moz-txt-link-rfc2396E" href="http://www.apple.com/developer/">&lt;http://www.apple.com/developer/&gt;</a><br class="">Apple Developer Relations, Developer Technical Support, Core OS/Hardware<br class=""><br class=""><br class="">_______________________________________________<br class="">swift-users mailing list<br class=""><a class="moz-txt-link-abbreviated" href="mailto:swift-users@swift.org">swift-users@swift.org</a><br class=""><a class="moz-txt-link-freetext" href="https://lists.swift.org/mailman/listinfo/swift-users">https://lists.swift.org/mailman/listinfo/swift-users</a><br class=""></div></div><div class="__pbConvHr" style="margin: 30px 25px 10px;"><div style="width: 1236px; border-top-width: 2px; border-top-style: solid; border-top-color: rgb(237, 241, 244); padding-top: 10px;" class=""><div style="display: inline-block; white-space: nowrap; vertical-align: middle; width: 605.625px;" class=""><a moz-do-not-send="true" href="mailto:john_brownie@sil.org" style="padding-right: 6px; font-weight: 500; color: rgb(72, 86, 100) !important; text-decoration: none !important;" class="">John Brownie</a></div><span class="Apple-converted-space">&nbsp;</span> <div style="display: inline-block; white-space: nowrap; vertical-align: middle; width: 593.265625px; text-align: right;" class=""><font color="#909AA4" class=""><span style="padding-left: 6px;" class="">28 September 2016 at 9:29</span></font></div></div></div><div __pbrmquotes="true" class="__pbConvBody" style="color: rgb(144, 154, 164); margin-left: 24px; margin-right: 24px;">I have a Swift wrapper for the expat XML parser, and I just went through the update to Swift 3, and I'm thrown a series of errors that mostly appear to be of two types. Here is a representative function of the first type:<span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">&nbsp;&nbsp;&nbsp; func parse() throws {<span class="Apple-converted-space">&nbsp;</span><br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var done = false<span class="Apple-converted-space">&nbsp;</span><br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while !done {<span class="Apple-converted-space">&nbsp;</span><br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let buffer: UnsafeMutablePointer&lt;Void&gt; = XML_GetBuffer(parser, Int32(bufsize))<span class="Apple-converted-space">&nbsp;</span><br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if buffer == nil {<span class="Apple-converted-space">&nbsp;</span><br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let errorCode = XML_GetErrorCode(parser)<span class="Apple-converted-space">&nbsp;</span><br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw ExpatError(reason: "Error \(errorCode), \(XML_ErrorString(errorCode))")<span class="Apple-converted-space">&nbsp;</span><br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<span class="Apple-converted-space">&nbsp;</span><br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let bytesRead = readData(UnsafeMutablePointer&lt;UInt8&gt;(buffer), bufferLength: bufsize)<span class="Apple-converted-space">&nbsp;</span><br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; done = bytesRead &lt; bufsize<span class="Apple-converted-space">&nbsp;</span><br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if XML_ParseBuffer(parser, Int32(bytesRead), Int32(done ? 1 : 0)) != XML_STATUS_OK {<span class="Apple-converted-space">&nbsp;</span><br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let errorCode = XML_GetErrorCode(parser)<span class="Apple-converted-space">&nbsp;</span><br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw ExpatError(reason: "Error \(errorCode), \(XML_ErrorString(errorCode))")<span class="Apple-converted-space">&nbsp;</span><br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<span class="Apple-converted-space">&nbsp;</span><br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<span class="Apple-converted-space">&nbsp;</span><br class="">&nbsp;&nbsp;&nbsp; }<span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">Xcode 8's migrator changed the declaration of buffer to UnsafeMutableRawPointer?, but the readData call gives an error:<span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">Cannot invoke initializer for type 'UnsafeMutablePointer&lt;UInt8&gt;' with an argument list of type '(UnsafeMutableRawPointer?)'<span class="Apple-converted-space">&nbsp;</span><br class="">Pointer conversion restricted: use '.assumingMemoryBound(to:)' or '.bindMemory(to:capacity:)' to view memory as a type.<span class="Apple-converted-space">&nbsp;</span><br class="">Overloads for 'UnsafeMutablePointer&lt;UInt8&gt;' exist with these partially matching parameter lists: (RawPointer), (OpaquePointer), (OpaquePointer?), (UnsafeMutablePointer&lt;Pointee&gt;), (UnsafeMutablePointer&lt;Pointee&gt;?)<span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">Where can I read up on how to make the conversion? My initial effort is:<span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let bytesRead = readData(buffer!.bindMemory(to: UInt8.self, capacity: bufsize), bufferLength: bufsize)<span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">That's more or less thrashing around with no real understanding.<span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">The second type is turning a closure into the appropriate C function pointer. For example:<span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XML_SetEndElementHandler(parser) { (userData: UnsafeMutableRawPointer, name: UnsafePointer&lt;XML_Char&gt;) -&gt; Void in<span class="Apple-converted-space">&nbsp;</span><br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let theParser = unsafeBitCast(userData, to: ExpatSwift.self)<span class="Apple-converted-space">&nbsp;</span><br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let theName = ExpatSwift.getString(name)<span class="Apple-converted-space">&nbsp;</span><br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; theParser.endElement(theName)<span class="Apple-converted-space">&nbsp;</span><br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">This gets an error:<span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">Cannot convert value of type '(UnsafeMutableRawPointer, UnsafePointer&lt;XML_Char&gt;) -&gt; Void' to expected argument type 'XML_EndElementHandler!'<span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">XML_EndElementHandler is defined as:<span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">typedef void (XMLCALL *XML_EndElementHandler) (void *userData,<span class="Apple-converted-space">&nbsp;</span><br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const XML_Char *name);<span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">Here I have no real clue as to how to fix it.<span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">So, any pointers to either how to fix these problems or to a good source to read to understand them?<span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">John<span class="Apple-converted-space">&nbsp;</span><br class=""></div></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""><div class="moz-signature" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);">--<span class="Apple-converted-space">&nbsp;</span><br class="">John Brownie<br class="">In Finland on furlough from SIL Papua New Guinea<br class=""></div><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); float: none; display: inline !important;" class="">swift-users mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""><a href="mailto:swift-users@swift.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class="">swift-users@swift.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-users" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""></div></blockquote></div><br class=""></body></html>