You can't just go calling C++ code from C.
You will need to produce a C++ interface that can be called from C.
Something like this
// interface.h
#ifdef __cplusplus
extern "C" {
#endif
void createMyclass();
void callMyclassSendCommandToSerialDevice(int Command, int Parameters, int DeviceId);
void destroyMyclass();
#ifdef __cplusplus
extern }
#endif
Then you do this:
static MyClass *myclass;
void createMyclass()
{
try
{
myclass = new MyClass;
}
catch(...)
{
fprintf(stderr, "Uhoh, caught an exception, exiting...\n");
exit(1);
}
}
void callMyclassSendCommandToSerialDevice(int Command, int Parameters, int DeviceId)
{
// May need try/catch here.
myclass->sendCommandToSerialDevice(Command, Parameters, DeviceId);
}
void destroyMyclass()
{
delete myclass;
}
Note that it's IMPERATIVE that you don't let "exceptions" through the wall to the C code, as that is definite undefined behaviour.