我正在尝试从 GitHub 编译yenom/BitcoinKit。问题出在 BitcoinKit.Private.swift 中。
错误是“'OpaquePointer' 类型的值没有成员 'pointee'”。
导致它的代码(留在注释掉的部分):
let privateKeyNum = BN_new()!
// other stuff in the file
// Check for invalid derivation.
//if BN_is_zero(privateKeyNum) {
// return nil
//}
if privateKeyNum.pointee.top == 0 { // BN_is_zero
return nil
}
现在,查看 BN_new 的 COpenSSL:
public func BN_new() -> OpaquePointer!
最后在 Swift、C、OpaquePointer 中:
/// A wrapper around an opaque C pointer.
///
/// Opaque pointers are used to represent C pointers to types that
/// cannot be represented in Swift, such as incomplete struct types.
@frozen public struct OpaquePointer {
/// Creates an `OpaquePointer` from a given address in memory.
public init?(bitPattern: Int)
/// Creates an `OpaquePointer` from a given address in memory.
public init?(bitPattern: UInt)
/// Converts a typed `UnsafePointer` to an opaque C pointer.
public init<T>(_ from: UnsafePointer<T>)
/// Converts a typed `UnsafePointer` to an opaque C pointer.
///
/// The result is `nil` if `from` is `nil`.
public init?<T>(_ from: UnsafePointer<T>?)
/// Converts a typed `UnsafeMutablePointer` to an opaque C pointer.
public init<T>(_ from: UnsafeMutablePointer<T>)
/// Converts a typed `UnsafeMutablePointer` to an opaque C pointer.
///
/// The result is `nil` if `from` is `nil`.
public init?<T>(_ from: UnsafeMutablePointer<T>?)
public init(_ from: UnsafeMutableRawPointer)
public init?(_ from: UnsafeMutableRawPointer?)
public init(_ from: UnsafeRawPointer)
public init?(_ from: UnsafeRawPointer?)
public static func != (lhs: OpaquePointer, rhs: OpaquePointer) -> Bool
}