stm32f103 using cpp11 and freertos by cubemx in keil

yukunduan wrote on Wednesday, July 11, 2018:

I’m using stm32f103c8t6 ,the editor is keil mdk.i must using c++11,so i change the misc controls to --cpp11 from c99 in keil . Then i add the freertos by STM32CubeMX, the freertos version is V9.0. F1 version is 1.6.0
when i complie it push error:
…/Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c(235): error: #513: a value of type “void *” cannot be assigned to an entity of type “BlockLink_t *”
…/Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c(317): error: #513: a value of type “void *” cannot be assigned to an entity of type “BlockLink_t *”
…/Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c(392): error: #513: a value of type “void *” cannot be assigned to an entity of type “A_BLOCK_LINK *”
…/Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c(400): error: #513: a value of type “void *” cannot be assigned to an entity of type “BlockLink_t *”
…/Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c(406): error: #513: a value of type “void *” cannot be assigned to an entity of type “BlockLink_t *”
…/Middlewares/Third_Party/FreeRTOS/Source/tasks.c(2806): error: #513: a value of type “void *” cannot be assigned to an entity of type “TCB_t *”
…/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.c(934): error: #513: a value of type “void *” cannot be assigned to an entity of type “osPoolId”
…/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.c(943): error: #513: a value of type “void *” cannot be assigned to an entity of type “std::uint8_t *”
…/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.c(1223): error: #513: a value of type “void *” cannot be assigned to an entity of type “os_mailQ_cb *”

The I force the type,until the editor can’t push the error messige like this:.
before :pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize );
change:pxNewBlockLink = ( void * ) ( ( ( BlockLinkt * ) pxBlock ) + xWantedSize );
But i find a prolem when mcu running .it stop in PendSv
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B .
ENDP
it means the editor does not recognized the Macro definition in FreertosConfig.h.
#define vPortSVCHandler SVC_Handler
#define xPortPendSVHandler PendSV_Handler
And the function define in port.c
__asm void vPortSVCHandler( void ).

But i fount something
1;it can run prvStartFirstTask
2.when i change the editor from cpp11 to c99, the system can run in normal
3.when i use STM32CUBEMX create the funtion of STM32F427,and change the project to cpp11 ,the complie go successful without an error.(F4 version is 1.18.0 )
i had compare the different about the FreeRtos between F4 and F1 , it just has a little different, also i have rechange the document,the F4 also complie well.
4.The config of F4 and F1 may just the FPU.

the next step i will using the transplant freertos from Official website download.

rtel wrote on Wednesday, July 11, 2018:

The FreeRTOS code in the SVN repository (not official release yet) has
replaced all void* handles with type safe handles (this could not be
done when it was first attempted due to bugs in GCC, but that seems to
be resolved now). That change may make C++ happier. However I would
recommend building the .c files as C, and only .cpp files as C++. Is
that an option in the compiler?

yukunduan wrote on Thursday, July 12, 2018:

thanks I will try to find this option.
i have a question ,why the same source code of freertos ,the stm32f4 can complie without no error in cpp11? Is that the different of CORTEX-M4 and CORTEX-M3?

rtel wrote on Thursday, July 12, 2018:

I think you are stating that an older version delivered by the cube
software compiles fine, but the latest version from the FreeRTOS
download does not. If so, I don’t know the answer, but as some of your
errors were in heap_4.c and I don’t think that file has changed in a
long time, I suggest you do a diff between the working and not working
heap_4.c files and report back with your findings so we can see what the
issue might be.