     case waitpid(Int32)
 }
 
+#if os(Windows)
+import func SPMLibc.strerror_s
+#else
 import func SPMLibc.strerror_r
+#endif
 import var SPMLibc.EINVAL
 import var SPMLibc.ERANGE
 
 extension SystemError: CustomStringConvertible {
     public var description: String {
         func strerror(_ errno: Int32) -> String {
+          #if os(Windows)
+            let cap = 128
+            var buf = [Int8](repeating: 0, count: cap)
+            let _ = SPMLibc.strerror_s(&buf, 128, errno)
+            return "\(String(cString: buf)) (\(errno))"
+          #else
             var cap = 64
             while cap <= 16 * 1024 {
                 var buf = [Int8](repeating: 0, count: cap)

///   - args: The executable arguments.
public func exec(path: String, args: [String]) throws {
    let cArgs = CStringArray(args)
    guard execv(path, cArgs.cArray) != -1 else {
        throw SystemError.exec(errno, path: path, args: args)
    }
}

// MARK: Utility function for searching for executables

                return "\(String(cString: buf)) (\(errno))"
            }
            fatalError("strerror_r error: \(ERANGE)")
          #endif
        }

        switch self {
