Skip to content

Avoid using NTSTATUS near exit(). #776

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

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Oct 21, 2024

On Windows, NTSTATUS is a typedef of long. On 32-bit Windows, long is imported into Swift as Int but on 64-bit Windows,it's imported as Int32. These types are layout-equivalent but not implicitly convertible, so we get errors on 32-bit Windows when using an NTSTATUS (i.e. Int) where a CInt (i.e. Int32) is expected.

This PR changes the types of the constants introduced in #766 to be explicitly CInt so that they are usable on both flavours of Windows.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

On Windows, `NTSTATUS` is a typedef of `long`. On 32-bit Windows, `long` is
imported into Swift as `Int` but on 64-bit Windows,it's imported as `Int32`.
These types are layout-equivalent but not implicitly convertible, so we get
errors on 32-bit Windows when using an `NTSTATUS` (i.e. `Int`) where a `CInt`
(i.e. `Int32`) is expected.

This PR changes the types of the constants introduced in #766 to be explicitly
`CInt` so that they are usable on both flavours of Windows.
@grynspan grynspan added bug 🪲 Something isn't working windows 🪟 Windows support exit-tests ☠️ Work related to exit tests labels Oct 21, 2024
@grynspan grynspan added this to the Swift 6.1 milestone Oct 21, 2024
@grynspan grynspan self-assigned this Oct 21, 2024
@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan grynspan merged commit 1cfb91e into main Oct 21, 2024
3 checks passed
@grynspan grynspan deleted the jgrynspan/Windows-32-bit-NTSTATUS-type branch October 21, 2024 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working exit-tests ☠️ Work related to exit tests windows 🪟 Windows support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants