[swift-users] Ugliness bridging Swift String to char *

Kenny Leung kenny_leung at pobox.com
Mon Mar 6 01:28:07 CST 2017


Follow-up on this:

The StaticString solution doesn’t work:

let separator: StaticString = “|”
opt.fieldSep = UnsafeMutablePointer(mutating: separator.utf8start)

… because utf8start returns UnsafePointer<UInt8>, and fieldSep is actually UnsafeMutablePointer<Int8>. There doesn’t seem to be any way to convert UnsafePointer<Unit8> to UnsafePointer<Int8>.

cString(using:) works because it returns [CChar], which is the same as Int8.

-Kenny

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170305/89e7cdb6/attachment.html>


More information about the swift-users mailing list