Skip to content

Conversation

@zamderax
Copy link
Contributor

@zamderax zamderax commented Oct 28, 2025

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.

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.

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
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd strongly prefer that we made these things internal, or at most package if we need them elsewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants