Skip to content
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

Use CInt and CUnsignedInt when calling C APIs #128

Merged
merged 1 commit into from Aug 12, 2019
Merged

Conversation

kevints
Copy link
Contributor

@kevints kevints commented Aug 12, 2019

Motivation:

On different platforms C may define int and unsigned to be different
types. When writing C interop code in Swift it's preferable to
use the CInt and CUnsignedInt typealiases as they will resolve to
the correct C type on all supported platforms. If the imported C API is
a definite-sized type, like uint32_t we leave the Swift type as
definitely-sized.

Modifications:

Use CInt instead of Int32 for C int parameters and CUnsignedInt
instead of UInt32 for C unsigned parameters.

Result:

Code is more portable and definite-sized types stand out.

Motivation:

On different platforms C may define `int` and `unsigned` to be different
types. When writing C interop code in Swift it's preferable to
use the `CInt` and `CUnsignedInt` typealiases as they will resolve to
the correct C type on all supported platforms. If the imported C API is
a definite-sized type, like `uint32_t` we leave the Swift type as
definitely-sized.

Modifications:

Use `CInt` instead of `Int32` for C `int` parameters and `CUnsignedInt`
instead of `UInt32` for C `unsigned` parameters.

Result:

Code is more portable and definite-sized types stand out.
Copy link
Member

@weissi weissi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! lgtm

@weissi weissi merged commit c8ac6c1 into apple:master Aug 12, 2019
@Lukasa Lukasa added the patch-version-bump-only For PRs that when merged will only cause a bump of the patch version, ie. 1.0.x -> 1.0.(x+1) label Aug 12, 2019
@Lukasa Lukasa added this to the 2.4.0 milestone Aug 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch-version-bump-only For PRs that when merged will only cause a bump of the patch version, ie. 1.0.x -> 1.0.(x+1)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants