I'm writing a compositor with Mir (links below) which only exposes a C++ API. Using bindgen this has mostly been a remarkably painless process but I have one case which always segfaults.
I don't understand C++ super well so my terminology may be of, but lets go:
When I take ownership of instances of certain classes, the application immediately segfaults unless I have marked these classes to only be included as opaque types, then the application segfaults whenever I try to pass it back too C++ in some way (method calls, as function args etc.).
One of these classes is
cpp file: https://github.com/MirServer/mir/blob/master/src/miral/window.cpp
h file: https://github.com/MirServer/mir/blob/master/include/miral/miral/window.h
example of problematic method:
I can however use methods that return pointers/references to these class instances and on them use methods or pass them around. Example of one such method:
So far I have worked around it by implementing c functions that call these methods, stores the instance and returns a pointer to the instance. It works but if it is possible to fix the problem without that, it would be great.