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.

  • Freddie Chopin

    You might find my project interesting – it’s a RTOS for ARM Cortex-M microcontrollers written entirely in C++11. http://distortos.org/ The things you can do in that case are way beyond a capabilities of any C++ wrapper possible. Imagine sending a complex object with move semantics via message queue (;

    • Thanks for the info! I had a look and your project seems promising. I have added a link to it in the page above.

      Regards, Geo

      • Freddie Chopin

        Great – thanks!