Problem compiling on STM32F405

Hey guys,

on my quest to make a RTOS project I encounter some problems.

I’m trying to run my program on a STM32F405, but compiling always fails.
I get the following message:

…/Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c:235:24: error: invalid conversion from ‘void*’ to ‘BlockLink_t* {aka A_BLOCK_LINK*}’ [-fpermissive]
pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Same thing for line 317, 400 and 406.
I feels like i searched the whole interent for a solution but all I could find was this: https://freertos.org/FreeRTOS_Support_Forum_Archive/November_2008/freertos_Compile_Error_using_g_2502218.html

I already tried to enforce C-files compiling with GNU C, but this didn’t help.

What makes this even stranger for me is the fact, that when I create a test project which compiles without any errors and copy heap_4.c from the test project, I still get errors.

Do you have any idea what might be the problem?

Thanks!

The error says that either you have some over-restrictive setting for the C compiler (that makes it non-conforming) or you are compiling the file as a C++ file, likely the latter.

One quick test would be to add some C++ only code to the file and see if it is accepted, maybe something like:

class test {
    int a;
};

If that doesn’t give an error, then you know it is being compiled as C++.

1 Like

As I get no error you seem to be right.

Do you have any idea how I can change this in CubeIDE?

I don’t have CubeIDE loaded at the moment, but you should check if there is a file extension to file type mapping setup somewhere. It might be in the project settings, or it might run off the IDE settings (Window / Preferences / File Types)

*.c files are already mapped as C Source Files in the IDE settings and I have also mapped C Source Files with GNU C but I still have this problem.
I guess I have to search for an alternative…

Are you building any code in the project as c++? If not just building with arm-none-eabi-gcc should make sure the c files are build as c code.

Unfortunately some files have to be build as C++.
I am currently evaluating whether platformio could be a suitable replacement for CubeIDE.

I think the compiler used in platform.io is going to be the same - you are still going to need to work out how to build the c files as c and the C++ files as C++.

For anyone having the same problem and searching for a solution: platformio might help.

It automatically detects the type of file and uses the correct compiler.

Thank you for taking time to report your solution.