Passing an Array of Strings From Swift to C
The type checker allows you to pass a
String
value to anUnsafePointer<Int8>
orUnsafePointer<UInt8>
parameter. When you do that, the compiler will transparently create a buffer containing the UTF-8-encoded, null-terminated string, and pass a pointer to that buffer to the function.[…]
However, some C functions take an array of strings (a
char **
orchar *[]
), and there is no built-in support in Swift for passing a[String]
to achar **
parameter.[…]
The full type of the
strlen
function as imported by Swift looks like this[…]
1 Comment RSS · Twitter
[…] Passing an Array of Strings From Swift to C, Swift 3.0 Unsafe World, Swift and C […]