From bb5fc482c7c9fc46aafafbee57bb2b3427f1ee2b Mon Sep 17 00:00:00 2001 From: Andrew Bettison Date: Mon, 30 Apr 2018 21:09:02 +0930 Subject: [PATCH] Fix Swift compile error on ARM 64-bit --- swift-daemon-api/Sources/CliContext.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/swift-daemon-api/Sources/CliContext.swift b/swift-daemon-api/Sources/CliContext.swift index 2e64e409..fdaae650 100644 --- a/swift-daemon-api/Sources/CliContext.swift +++ b/swift-daemon-api/Sources/CliContext.swift @@ -101,11 +101,24 @@ private func cliPuts(_ context: UnsafeMutablePointer?, _ str: Unsaf } } +// The va_list C type on i386, armv7 and i86_64 is CVaListPointer, whereas on +// arm64 it is Optional. +#if arch(arm64) + +private func cliVprintf(_ context: UnsafeMutablePointer?, _ fmt: UnsafePointer?, _ ap: CVaListPointer?) -> Void { + let str = NSString(format: String(cString: fmt!), arguments: ap!) + _self(context).putString(String(data: str.data(using: String.Encoding.utf16.rawValue)!, encoding:.utf16)!) +} + +#else + private func cliVprintf(_ context: UnsafeMutablePointer?, _ fmt: UnsafePointer?, _ ap: CVaListPointer) -> Void { let str = NSString(format: String(cString: fmt!), arguments: ap) _self(context).putString(String(data: str.data(using: String.Encoding.utf16.rawValue)!, encoding:.utf16)!) } +#endif + private func cliPutLong(_ context: UnsafeMutablePointer?, _ value: Int64, _ delim: UnsafePointer?) -> Void { _self(context).putLong(value, delim != nil ? String(cString: delim!) : nil) }