在main.swift
文件中,我们调用了收据检查系统(由Receigen生成)。在 Swift 2 中,main.swift
阅读:
startup(Process.argc, UnsafeMutablePointer<UnsafePointer<Int8>>(Process.unsafeArgv))
升级到 Swift 3 后,我已经做到了:
startup(CommandLine.argc, UnsafeMutablePointer<UnsafePointer<Int8>>(CommandLine.unsafeArgv))
显示错误:
无法将类型
UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>
(akaUnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>
) 的值转换为预期的参数类型UnsafeMutablePointer<_>
更新:使用链接的问题,使其内容为:
startup(CommandLine.argc, UnsafeMutableRawPointer(CommandLine.unsafeArgv)
.bindMemory(
to: UnsafeMutablePointer<Int8>.self,
capacity: Int(CommandLine.argc)))
产生:
无法将类型的值转换
UnsafeMutablePointer<Int8>.Type
为预期的参数类型UnsafePointer<Int8>?.Type
(又名Optional<UnsafePointer<Int8>>.Type
)
编译器指的是to:UnsafeMutablePointer
.
启动的标头如下所示:
int startup(int argc, const char * argv[]);
如何成功地将变量传递给 startup in main.swift
?