Skip to content

Commit d9ef817

Browse files
committed
Fix building on Windows
1 parent 2bc160b commit d9ef817

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

Package.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,19 @@
1212

1313
import PackageDescription
1414

15-
let targets: [PackageDescription.Target] = [
15+
var windowsPlatform: [Platform] = []
16+
#if os(Windows)
17+
windowsPlatform.append(.windows)
18+
#endif
19+
20+
let targets: [Target] = [
1621
.target(
1722
name: "SystemPackage",
1823
dependencies: ["CSystem"],
1924
path: "Sources/System",
25+
cSettings: [
26+
.define("_CRT_SECURE_NO_WARNINGS", .when(platforms: windowsPlatform)),
27+
],
2028
swiftSettings: [
2129
.define("SYSTEM_PACKAGE"),
2230
.define("ENABLE_MOCKING", .when(configuration: .debug))

Sources/System/Internals/Mocking.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private func originalSyscallName(_ function: String) -> String {
146146

147147
private func mockImpl(
148148
name: String,
149-
path: UnsafePointer<CChar>?,
149+
path: UnsafePointer<CInterop.PlatformChar>?,
150150
_ args: [AnyHashable]
151151
) -> CInt {
152152
precondition(mockingEnabled)
@@ -177,18 +177,18 @@ private func mockImpl(
177177
}
178178

179179
internal func _mock(
180-
name: String = #function, path: UnsafePointer<CChar>? = nil, _ args: AnyHashable...
180+
name: String = #function, path: UnsafePointer<CInterop.PlatformChar>? = nil, _ args: AnyHashable...
181181
) -> CInt {
182182
return mockImpl(name: name, path: path, args)
183183
}
184184
internal func _mockInt(
185-
name: String = #function, path: UnsafePointer<CChar>? = nil, _ args: AnyHashable...
185+
name: String = #function, path: UnsafePointer<CInterop.PlatformChar>? = nil, _ args: AnyHashable...
186186
) -> Int {
187187
Int(mockImpl(name: name, path: path, args))
188188
}
189189

190190
internal func _mockOffT(
191-
name: String = #function, path: UnsafePointer<CChar>? = nil, _ args: AnyHashable...
191+
name: String = #function, path: UnsafePointer<CInterop.PlatformChar>? = nil, _ args: AnyHashable...
192192
) -> _COffT {
193193
_COffT(mockImpl(name: name, path: path, args))
194194
}

0 commit comments

Comments
 (0)