class myDevice { private: // Here goes what in C was the MY_DEVICE_INFO struct MY_DEVICE_SETTINGS m_settings; /* Settings struct of the device */ void *m_bd_info; /* private info of bus driver */ HNDLE m_hkey; /* ODB key for bus driver info */ INT m_channels; /* number of channels */ public: myDevice( HNDLE hkey, INT channels, INT(*bd) (INT cmd, ...) ) { // Here goes what in C was my_device_init } INT myCommand(INT channel, ... /* other arguments */ ) { // Implementation of my_command } ~myDevice() { // Here goes what in C was my_device_exit } }; /*---- device driver entry point -----------------------------------*/ INT my_device(INT cmd, ...) { va_list argptr; HNDLE hKey; INT channels, channel, status; float *pvalue; myDevice *pMyDevice; INT (*bd) (INT, ...); va_start(argptr, cmd); status = FE_SUCCESS; switch (cmd) { case CMD_INIT: hKey = va_arg(argptr, HNDLE); pMyDevice = va_arg(argptr, myDevice *); channels = va_arg(argptr, INT); va_arg(argptr, DWORD); // flags bd = va_arg(argptr, INT (*) (INT, ...)); try { pMyDevice = new myDevice(hKey, channels, bd); } catch (const std::exception& e) { cm_msg(MERROR, __func__, " init: %s", e.what()); status = FE_ERR_DRIVER; }; break; case CMD_MY_COMMAND: pMyDevice = va_arg(argptr, myDevice *); channel = va_arg(argptr, INT); // other arguments try { status = pMyDevice->myCommand(channel, /* other arguments */); } catch (const std::exception& e) { cm_msg(MERROR, __func__, " my command: %s", e.what()); if (status == FE_SUCCESS) status = FE_ERR_DRIVER; } break; case CMD_EXIT: pMyDevice = va_arg(argptr, myDevice *); pMyDevice->~myDevice(); break; default: break; } va_end(argptr); return status; }