FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [September 2014 Threads] FreeRTOS and C++ STL compatabilityPosted by sinakahnemouyi1 on September 16, 2014 Hi,
I was wondering if FreeRTOS is compatible with C++ STL (containers such as list, vector). FreeRTOS tasks use thread safe allocators, however STLs use simple malloc, and free functions. Is there anyway to make this work?
Thanks
FreeRTOS and C++ STL compatabilityPosted by edwards3 on September 17, 2014 If you can redirect the compiler to a different malloc and free implementation (common with compilers, check the command options) then use heap_3.c and redirect malloc() to pvPortMalloc() and free() to vPortFree(). That will take care of the memory allocation, not sure about the rest.
FreeRTOS and C++ STL compatabilityPosted by sinakahnemouyi1 on September 18, 2014 Thank you MEdwards. I am using Kinetis Design Studio which is an Eclipse based IDE and I was able to enable multiple definitions in the compiler by adding the following flag to the C/C++ linker:
-z muldefs
This allowed me to override the malloc and free functions for FreeRTOS and solved the problem. This can be done in the main.c file:
extern void malloc(size_t size);
extern void free (void ptr);
void *malloc(size_t size)
{
void *result;
result = FRTOS1_pvPortMalloc(size);
return result;
}
void free (void* ptr){
FRTOS1_vPortFree(ptr);
}
Best,
Sina
FreeRTOS and C++ STL compatabilityPosted by rtel on September 18, 2014 Maybe just where you have types the code in here, but note the prototype of the malloc() function you posted is not correct. It needs to return a void *, not just a void. I imagine this is correct in your real code otherwise the compiler would complain.
Regards.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|