Skip to content

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

Merged
merged 1 commit into from
Dec 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions stdlib/public/Platform/Platform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
import SwiftShims
import SwiftOverlayShims

#if os(Windows)
import ucrt
#endif

#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
//===----------------------------------------------------------------------===//
// MacTypes.h
Expand Down Expand Up @@ -132,6 +136,14 @@ public func snprintf(ptr: UnsafeMutablePointer<Int8>, _ len: Int, _ format: Unsa
return vsnprintf(ptr, len, format, va_args)
}
}
#elseif os(Windows)
public var stdin: UnsafeMutablePointer<FILE> { return __acrt_iob_func(0) }
public var stdout: UnsafeMutablePointer<FILE> { return __acrt_iob_func(1) }
public var stderr: UnsafeMutablePointer<FILE> { return __acrt_iob_func(2) }

public var STDIN_FILENO: Int32 { return _fileno(stdin) }
public var STDOUT_FILENO: Int32 { return _fileno(stdout) }
public var STDERR_FILENO: Int32 { return _fileno(stderr) }
#endif


Expand Down
6 changes: 6 additions & 0 deletions stdlib/public/Platform/ucrt.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ module ucrt [system] {

module corecrt {
header "corecrt.h"
header "corecrt_stdio_config.h"
export *

module io {
Expand All @@ -122,6 +123,11 @@ module ucrt [system] {
header "corecrt_math.h"
export *
}

module stdio {
header "corecrt_wstdio.h"
export *
}
}
}