import WinSDK.User
import Swift
public extension String {
var LPCWSTR: [UInt16] {
return self.withCString(encodedAs: UTF16.self) { buffer in
Array<UInt16>(unsafeUninitializedCapacity: self.utf16.count + 1) {
wcscpy_s($0.baseAddress, $0.count, buffer)
$1 = $0.count
}
}
}
}
MessageBoxW(UnsafeMutablePointer<HWND__>(nil), "Swift".LPCWSTR, "Swift".LPCWSTR, UINT(MB_OK));
Building the simple winsdk project above outputs the following error:
lld-link: error: undefined symbol: __declspec(dllimport) MessageBoxW
>>> referenced by C:\Users\x1398\CLionProjects\SwiftNewTest\.build\x86_64-unknown-windows-msvc\debug\SwiftNewTest.build\main.swift.o:(main)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[3/4] Linking C:\Users\x1398\CLionProjects\SwiftNewTest\.build\x86_64-unknown-windows-msvc\debug\SwiftNewTest.exe
It seems that it can't locate user32.lib.
PS: Module maps are copied as guided in the x64 native prompt.