cancel
Showing results for 
Search instead for 
Did you mean: 

freertos with c++ library in cubeide

HKang.4
Associate

Hi, I'm new to building by using CubeIDE

Actaully, I'm kind of lost for building my project.

When applying freeRTOS provided by CUBEIDE, a freertos.c file is generated. I want to use including a C++ header file and C++source code and using a C++ class created in the C++ source code in my freertos.c file. I changed the targeted language to C++ and renaming main.c to main.cpp. Then, if I use #include "myown.h" (based by c++) and

extern "C" MX_FREERTOS_Init(); in prototype.

And when I bulid, warning appears

" ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

at freertos.cpp."

osThreadDef(AGLORITHM, Algorithm, osPriorityAboveNormal, 0, 128);

warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

 osThreadDef(AGLORITHM, Algorithm, osPriorityAboveNormal, 0, 128);

../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.h:416:4: note: in definition of macro 'osThreadDef'

 416 | { #name, (thread), (priority), (instances), (stacksz), NULL, NULL }

   |  ^~~~

What should I do for this ?

1 REPLY 1

HKang.4 first things first, Cubeide is not well suited for cpp. second, your main file should be changed to .cpp instead of c. third in cpp you can not throw different types to each other, in other words, in case of necessity casting is mandatory. forth, That function you mentioned doesn't exist in cube-generated code, pitty, you should add it your self, cube developers don't think cpp but c like.