Passing an array of pointers to C

I'm working with a C function that takes an array of pointers (specifically, git_commit_create() from libgit2), and the type of that parameter comes through as UnsafeMutablePointer<OpaquePointer?>!. I have the OpaquePointers in an array, so how do I convert that to something I can pass to this function?

I tried simply doing &pointerArray but the compiler said "Cannot convert value of type '[OpaquePointer]' to expected argument type 'OpaquePointer?'".

The elements of the array have to be optional, just in case git_commit_create is going to store NULL back into them. (Of course git_commit_create isn't actually going to modify the parents array, but it's missing the appropriate const to indicate that.)

Thanks! Changing the array declaration to be explicitly of type [OpaquePointer?] fixed it up nicely.

Terms of Service

Privacy Policy

Cookie Policy