Home > Blockchain >  Cannot find 'strideofValue' in scope
Cannot find 'strideofValue' in scope

Time:09-16

I am getting:

Cannot find 'strideofValue' in scope

For below code:

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
}

How can I fix the logic?


I tried stride(ofValue:), but that just causes another strange issue:

Type of expression is ambiguous without more context

(With strange I mean that, it should say something like, function exists but not with ofValue label)

CodePudding user response:

There is no strideofValue function in Swift 5, replace strideofValue(info) with MemoryLayout.stride(ofValue: info).

  • Related