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

fclose takes Nonnull FILE pointer in Swift >=5.9 #430

Closed
wants to merge 1 commit into from
Closed

fclose takes Nonnull FILE pointer in Swift >=5.9 #430

wants to merge 1 commit into from

Conversation

tokyovigilante
Copy link

@tokyovigilante tokyovigilante commented May 23, 2023

Closes #429.

@Lukasa
Copy link
Contributor

Lukasa commented May 24, 2023

@swift-server-bot test this please

@Lukasa Lukasa added the semver/patch No public API change. label May 24, 2023
Copy link
Contributor

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

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

Unfortunately this needs a bit of a tweak, as right now the change affects both Linux and Apple platforms, where the signature hasn't changed.

Can you use the per-OS blocks below to make this change affect only Linux?

@Lukasa
Copy link
Contributor

Lukasa commented Jun 5, 2023

@swift-server-bot test this please

@Lukasa
Copy link
Contributor

Lukasa commented Jun 5, 2023

Hmm, this appears to be a bit overzealous, as our CI is failing the build:

16:45:30 /code/Sources/NIOSSL/PosixPort.swift:44:63: error: C function pointer signature '(UnsafeMutablePointer<FILE>?) -> Int32' (aka '(Optional<UnsafeMutablePointer<_IO_FILE>>) -> Int32') is not compatible with expected type '@convention(c) (FILEPointer) -> CInt' (aka '@convention(c) (UnsafeMutablePointer<_IO_FILE>) -> Int32')

What Linux distribution did you test on?

@tokyovigilante
Copy link
Author

tokyovigilante commented Jun 7, 2023

What Linux distribution did you test on?

Fedora rawhide, with Clang 16 and glibc 2.37.9.

@Lukasa
Copy link
Contributor

Lukasa commented Jun 12, 2023

This is probably more that combination. We can probably get around this by redeclaring the variable as a closure wrapping the underlying function:

private let sysFclose: @convention(c) (FILEPointer?) -> CInt = { fclose($0) }

@Saljooq
Copy link
Contributor

Saljooq commented Nov 1, 2023

@Lukasa I tried your fix but the argument had to be unwrapped, this is the version that worked:

private let sysFclose: @convention(c) (FILEPointer?) -> CInt =  { fclose($0!) }

cc: @tokyovigilante

@tokyovigilante tokyovigilante closed this by deleting the head repository Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compilation fails on Linux with Swift 5.9-dev
3 participants