[swift-users] Ambiguous error for setting a value in a CChar array

Adam Campbell adam.92.ac at gmail.com
Thu Mar 3 21:54:46 CST 2016

Discovered this when trying to answer a stackoverflow question about
setting character values in a CCString array.

The following code produces an ambiguous error:
var buff = [CChar](count: 5, repeatedValue: 0)
buff[0] = "A".utf8.first!.value // Error - Cannot assign value of type
'Int8' to type 'CChar' (aka 'Int8')

I can easily get around this by changing the second line to:
buff[0].value = "A".utf8.first!.value

Can someone explain what is happening here? As well as the significance of

Thanks in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160304/ee80c3fb/attachment.html>

More information about the swift-users mailing list