I am coding a c++ wrapper to listen messages coming from the CAN bus for an ARM7 processor, and need to launch a task for callback function. I define the callback function as static as usual when using threads. When compiling the following error appears:
error: #167: argument of type "void (*)(void*)" is incompatible with parameter of type "void (*)(void *) C"
What am i doing wrong? It is possible to launch a task inside a class?
Source code sample:
void taskCallBack( void* pthis ) __task; class BusCAN { public: CAN_ERROR start( bool listen ); virtual void onMessage( CAN_msg *msg ) = NULL; private: static void taskCallBack( void* pthis ) __task; // ... }; CAN_ERROR BusCAN::start( bool listen ) { CAN_ERROR canError = CAN_start( CANCtrl ); os_tsk_create_ex( taskCallBack, listenPriority, this ); return canError; } void taskCallBack( void* pthis ) __task { CAN_msg msg_rece; for (;;) { // Do something } }
Thanks in advance.