NIOPosix: add Windows compatibility shims for environment APIs#3427
Open
zamderax wants to merge 1 commit intoapple:mainfrom
Open
NIOPosix: add Windows compatibility shims for environment APIs#3427zamderax wants to merge 1 commit intoapple:mainfrom
zamderax wants to merge 1 commit intoapple:mainfrom
Conversation
Lukasa
reviewed
Oct 30, 2025
Contributor
Lukasa
left a comment
There was a problem hiding this comment.
This is broadly good, just left a note about visibility.
| /// Standard POSIX-style file descriptor numbers used by example code and tests. | ||
| public let STDIN_FILENO: CInt = 0 | ||
| public let STDOUT_FILENO: CInt = 1 | ||
| public let STDERR_FILENO: CInt = 2 |
Contributor
There was a problem hiding this comment.
I'd strongly prefer that we made these things internal, or at most package if we need them elsewhere.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Windows doesn't provide the POSIX helpers NIO uses (like setenv and standard file descriptor constants), causing compilation failures in NIOCrashTester and the HTTP server example.
This adds a Windows-only compatibility shim in NIOPosix that provides POSIX-style equivalents using Windows APIs (_putenv_s, etc.). This lets Windows use the same source code without #if os(Windows) scattered throughout.
Validated with swift build -c debug --product NIOPosix on Linux.