New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-466] Imported APIs taking chars should use CChar #43083
Comments
@DougGregor, @lattner, any opinions? |
Seems reasonable to me. |
I don't have a strong opinion on it, I was sort of hoping that all the C* types would go away someday. I agree that in this case, CChar does serve a useful purpose though. |
Is this resolved or no longer being considered? If so, it should be closed. |
I think we could still do it. It's not ABI-breaking, since the CChar typealias is fixed for each platform. (We also don't have a CSignedChar, which we'd probably want.) |
If imported APIs would expose a CChar instead of a raw Int8 or Uint8, we could avoid the illusion of a mismatch with other Swift APIs. For example, String.utf8CString returns a ContiguousArray<CChar>. If we had CChar everywhere, no one would ever wonder how to write correct platform-independent code. This message is a follow-up of https://forums.swift.org/t/is-there-is-mismatch-between-string-utf8cstring-and-imported-c-declarations/21013 |
Tagging as a StarterBug. All the pieces for this are in place, so what's left is: 1. Remove the entries for Char_U, Char_S, WChar_S, and WChar_U from BuiltinMappedTypes.def. These represent |
If |
It's already using CWideChar; the only difference is that it looks through the typealias at the point of import, and now we'll be preserving the typealias. That won't change anything in the ABI. |
I ran into this, discovered the forum post, which lead me here. #32692 |
Additional Detail from JIRA
md5: fb3d11a5978519172603e14b926036d4
Issue Description:
I don’t know if/when Swift will be ported to a platform where the character type is unsigned but perhaps imported APIs where the character signedness is not explicitly specified should be imported as CChar rather than Int8?
Documentation says that CChar is the native character type.
The text was updated successfully, but these errors were encountered: