Converting Opaque** to [Opaque]

You are saying the same thing. Where you say "opaque type", @eskimo says "incomplete struct", but you both mean the same thing: a C structure whose name you know but whose size you do not.

In this case, the public header files for GLFW seem not to include a definition for struct GLFWmonitor, which means that by definition it is incomplete or opaque. The type exists, but you don't know anything about its size. In Swift, pointers to such a type are aways OpaquePointer (see Opaque Pointers in Swift for a discussion of the pros and cons of this).

I don't know why CLion is getting this wrong, but wherever it is getting the type definitions from it has access to the actual structure definition and so is concluding the wrong thing about the type. The variable monitors therefore has the type UnsafeMutablePointer<OpaquePointer?>!, as @eskimo has noted.

Answering this more specifically: no, they cannot be. structs have size, they have layout, they can be copied around. Opaque types have no known size, no known layout, they cannot be held.

1 Like