Answer the question
In order to leave comments, you need to log in
How to call a C++ class method, callback from a C library?
Hello. Congratulations, colleagues.
There is a C library that reads data from the COM port in a separate thread and forms data packets from them.
There is a C++ application based on wxWidgets, which should receive data from the library as it accumulates.
In the class describing the frame, wxWidget made a static property that stores a pointer to an object of this class (so that you can work in the static method in the context of the object) and a static method that is passed to the library as a pointer to the callback function. Everything would be fine, but for some reason, when accessing the frame elements from the callback function, the application crashes with the SIGABRT signal. How can this problem be solved? Thank you.
Answer the question
In order to leave comments, you need to log in
As far as I remember, wxWidgets is not able to handle function calls from other threads.
Most likely this is not a problem of interaction between C and C ++. To be sure, run the application in gdb and show the stacktrace at the moment the signal is received.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question