-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Platform: make MSVCRT more Unix-libc like #21293
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
Conversation
CC: @jrose-apple |
@swift-ci please test |
I realized that I can play some indirection tricks and reduce the amount of code that needs to be effectively "if-defed", and this also makes user code be similar across platforms, so I think that this is an improvement. |
stdlib/public/Platform/msvcrt.swift
Outdated
// Unfortunately, the clang importer does not import "complex" macros such as | ||
// the one that are used in the UCRT for defining `stdin`, `stdout`, `stderr`. | ||
// Replicate them manually. | ||
public var stdin: UnsafeMutablePointer<FILE> { return __acrt_iob_func(0) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These variables are already defined in Platform.swift
under a guard. Wouldn't it be better to have them in the same place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sigh I had forgotten about that. Thanks! Yes, these belong there.
Since `stdin`, `stdout`, and `stderr` are defined via macros, we cannot see them on the swift side. Replicate these by hand. Expose `STDIN_FILENO`, `STDOUT_FILENO`, and `STDERR_FILENO` for compatibility with other libc implementations. This reduces the need for changing the codebase unnecessarily for MSVCRT.
09f299d
to
04a5d84
Compare
@swift-ci please test |
Build failed |
Build failed |
Since
stdin
,stdout
, andstderr
are defined via macros, we cannot see themon the swift side. Replicate these by hand. Expose
STDIN_FILENO
,STDOUT_FILENO
, andSTDERR_FILENO
for compatibility with other libcimplementations. This reduces the need for changing the codebase unnecessarily
for MSVCRT.
Replace this paragraph with a description of your changes and rationale. Provide links to external references/discussions if appropriate.
Resolves SR-NNNN.