Compiling FreeRTOS With C++

Compiling FreeRTOS With C++

It can be done. See “Is It Possible To Create A FreeRTOS Task In C++” for some helpful information.

One of the main problems is that you can’t use a member function as a task (due to the in-ability to take a pointer to a member function). There is a way around this, which is to pass in the object as part of the pvParameters variable, and then create a wrapper function which casts this variable back into a function pointer.

Yuriy Kulikov has made a neat FreeRTOS Framework for C++. I have had problems with his use of the virtual function, and had to modify it slightly.

Alternatives

A alternative to modifying/wrapping FreeRTOS for a C++ environment is to use a RTOS which is explicitly designed for C++. distortos is one such promising example. As of Dec 2016, it is not as well supported as FreeRTOS, but has active development.