C++ function:
Code Block int test(test_type type, request_info_t *request, size_t request_len) { size_t size = request_len; int mib[] = {0,0,0,0,0}; int ret = sysctl(mib, 5, request, &size, NULL, 0) return ret; }
Swift function:
Code Block func test( type: test_type, request: request_info_t, request_len: size_t) -> Int64 { let size: Int = request_len let mib: [Int]= [0, 0, 0, 0, 0] let val: Int32 = sysctl(mib, 5, request, size, nil, 0) return val }
But I am facing below issues with arguments at sysctl(). Could any one please to convert this.
Error due to first argument mib: Cannot convert value of type '[Int]' to expected argument type 'UnsafeMutablePointer<Int32>?'
Error due to third argument request: Cannot convert value of type 'Int' to expected argument type 'UnsafeMutablePointer<Int>?'
Error due to fourth argument size: Cannot convert value of type 'requestinfot' to expected argument type 'UnsafeMutableRawPointer?'