在范围内找不到 'strideofValue'

Cannot find 'strideofValue' in scope

我得到:

Cannot find 'strideofValue' in scope

对于以下代码:

public static func isDebuggerAttached() -> Bool {
    var info = kinfo_proc()
    var mib : [Int32] = [CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()]
    var size = strideofValue(info)
    let junk = sysctl(&mib, UInt32(mib.count), &info, &size, nil, 0)
    assert(junk == 0, "sysctl failed")
    return (info.kp_proc.p_flag & P_TRACED) != 0
}

我该如何修正逻辑?


我尝试了 stride(ofValue:),但这只会导致另一个奇怪的问题:

Type of expression is ambiguous without more context

(我的意思是奇怪,它应该说类似的东西,功能存在但不带有 ofValue 标签)

Swift中没有strideofValue功能 5、将strideofValue(info)替换为MemoryLayout.stride(ofValue: info)