You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Swift currently doesn't provide good facilities for passing arguments to methods that take in char * const _[] in C, which get mapped to UnsafePointer<UnsafeMutablePointer<Int8>>. The closest solution I've found (https://www.reddit.com/r/swift/comments/3r5027/char_in_swift/) requires some legwork.
Additional Detail from JIRA
md5: 9fef48dfcb05d6f5109d915a1154149d
Issue Description:
Swift currently doesn't provide good facilities for passing arguments to methods that take in char * const _[] in C, which get mapped to UnsafePointer<UnsafeMutablePointer<Int8>>. The closest solution I've found (https://www.reddit.com/r/swift/comments/3r5027/char_in_swift/) requires some legwork.
let arguments = ["bash", "-c", "echo foo"]
let argv: UnsafeMutablePointer<UnsafeMutablePointer<CChar>> = arguments.withUnsafeBufferPointer {
let buffer = UnsafeMutablePointer<UnsafeMutablePointer<CChar>>.alloc($0.count + 1)
buffer.initializeFrom($0.map { $0.withCString(strdup) })
buffer[$0.count] = nil
return buffer
}
Whether it be done in the compiler or through new APIs in the standard library, there really should be a better solution for this.
The text was updated successfully, but these errors were encountered: