Skip to content

Commit db34d9f

Browse files
fabianfettzaneenders
authored andcommitted
[Windows] Ensure NIOEmbedded compiles (#3319)
Make NIOEmbedded compile.
1 parent d13f845 commit db34d9f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Sources/NIOEmbedded/Embedded.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import Darwin
3232
@preconcurrency import Android
3333
#elseif canImport(WASILibc)
3434
@preconcurrency import WASILibc
35+
#elseif canImport(WinSDK)
36+
@preconcurrency import WinSDK
3537
#else
3638
#error("Unknown C library.")
3739
#endif
@@ -41,7 +43,12 @@ private func printError(_ string: StaticString) {
4143
var buf = buf
4244
while buf.count > 0 {
4345
// 2 is stderr
46+
#if canImport(WinSDK)
47+
let rc = _write(2, buf.baseAddress, UInt32(truncatingIfNeeded: buf.count))
48+
let errno = GetLastError()
49+
#else
4450
let rc = write(2, buf.baseAddress, buf.count)
51+
#endif
4552
if rc < 0 {
4653
let err = errno
4754
if err == EINTR { continue }

0 commit comments

Comments
 (0)