L
L
link_irk2014-09-13 04:43:19
C++ / C#
link_irk, 2014-09-13 04:43:19

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

2 answer(s)
J
jcmvbkbc, 2014-09-13
@link_irk

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.

L
link_irk, 2014-09-15
@link_irk

Thank you. Problem solved by events.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question