Having trouble with a cinterop library. I'm using ...
# kotlin-native
w
Having trouble with a cinterop library. I'm using vulkan on the mingwx64 target. It provides a function
vkGetInstanceProcAddr
which fetches a ptr to a function. cinterop maps this to
CPointer<() -> Unit>
by default but I need to cast this to a different function typealias. The typealias is
PFN_vkCreateDebugUtilMessengerEXT
. To cast this and call it I run
_vkGetInstanceProcAddr_(instance.ptr, "vkCreateDebugUtilsMessengerEXT")!!.reinterpret<PFN_vkCreateDebugUtilMessengerEXTVar>().pointed.value!!
this returns successfully. When I attempt to invoke it, no exception is thrown, nothing is written to stdout, it simply exits the runtime right there with no other notifications. Am I performing this cast correctly, and if so, can you think of something I can do to debug this behavior?
1
Sorry, I have a habit of trying to figure out something for a day, then posting, and then figuring it out shortly after. In my case, the cast was incorrect. the *Var types are essentially pointers to pointers. I used that because reinterpret required a pointed type. The correct thing to do was to reinterpret the original function pointer to another
CFunction<>
type.
PFN_vkCreateDebugUtilMessengerEXT
was of type
CPointer<CFunction< ... >>
so I reinterpreted the original pointer with the type in there and it works fine. Rather than looking up the correct signature to put there, it'd be nice if cinterop provided a typealias for just the CFunction part of the function pointer. I'll put in a youtrack for it.