Compiler errors in the queue.c file

ksoldavin wrote on Monday, March 21, 2011:

I am attempting to compile FreeRTOS 6.1.1 with IAR ARM compiler version 6.05 but I keep running into an error with a specific compiler option. I want to compile the code with the “Multi-file Compilation” option enabled but I always get errors in the queue.c file. An example of the errors I get is “declaration of function “xQueueTakeMutexRecursive” is incompatible with a declaration in another translation”. I get roughly 15 errors in this file. If I remove the compiler option the code compiles perfectly and runs fine. Does anyone have any idea why these errors are coming up and how to avoid them?

Thank you

rtel wrote on Monday, March 21, 2011:

I have never tried using that compiler options, so the following is just a guess:

The (deliberate) data hiding in the FreeRTOS kernel means that something like an xQueueHandle is a pointer to a structure inside the queue.c source file, but a pointer to a void * in all other files.  It sounds like the compiler cannot cope with that when that particular option is used.


richard_damon wrote on Monday, March 21, 2011:

The problem is that the “Multi-file Compilation” option does not work with a mixed language project.  The FreeRTOS kernel files must be compiled truly as C code, not C++ due to the way the data hiding is done (and a few other Cisms in the code, not surprising since it is C code).

You will either need to convert the code to be valid C++ code, which to start means changing the definition of handles from void * to being struct xxxx* (xxx depending on the given handle), which may kick up a few other errors, or you need to turn off the “Multi-file Compilation” option (this is what I did). You may also be able to change your project to compile FreeRTOS into a library module, and include that in your main project if you really need to use the Multi-file option.

ksoldavin wrote on Monday, March 21, 2011:

Thank you for the input. The reason I wanted to try the multiple file option was to help the optimizer remove more unused code. I will try to compile the RTOS as a library without that option and then include it in my project.