xSTATIC_QUEUE had a different meaninf during compilation

kat123 wrote on Wednesday, February 28, 2018:

Trying to compile FreeRTOS+TCP with IAR EWARM.

I get an error

Error[Pe1066]: declaration of struct “xSTATIC_QUEUE” had a different meaning during compilation of “…\Middlewares\Third_Party\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\BufferManagement\BufferAllocation_2.c” C:\Users\StephensKa\Documents\Combined Pulsed\Firmware_local\trunk\Middlewares\Third_Party\FreeRTOS\Source\include\FreeRTOS.h 1046"
struct “xSTATIC_QUEUE” (declared at line 1046) (from translation unit “…\trunk\Src\main.c”)
struct “xSTATIC_QUEUE” (declared at line 1046) (from translation unit “…\trunk\Middlewares\Third_Party\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\BufferManagement\BufferAllocation_2.c”)
detected during compilation of secondary translation unit “…\trunk\Src\main.c”

However when I search the code for xSTATIC_QUEUE I only find 1 instance of it.

Is there any way to fix this error/

rtel wrote on Wednesday, February 28, 2018:

xSTATIC_QUEUE is defined in a header file, so it might be something to
do with the order in which header files are being included.
BufferAllocation_2.c is one of our files, so hopefully the header files
are correct. Could you please post the part of your main.c file that
includes the header files.

heinbali01 wrote on Wednesday, February 28, 2018:

The definition of xSTATIC_QUEUE depends on four defines from FreeRTOSConfig.h.

You can test how the preprocessor sees them by issuing temporary warnings from FreeRTOS.h:

#if( configSUPPORT_STATIC_ALLOCATION != 0 )
    #warning STATIC_ALLOCATION yes
#else
    #warning STATIC_ALLOCATION no
#endif

#if( configSUPPORT_DYNAMIC_ALLOCATION != 0 )
    #warning DYNAMIC_ALLOCATION yes
#else
    #warning DYNAMIC_ALLOCATION no
#endif

#if( configUSE_QUEUE_SETS != 0 )
    #warning QUEUE_SETS yes
#else
    #warning QUEUE_SETS no
#endif

#if( configUSE_TRACE_FACILITY != 0 )
    #warning TRACE_FACILITY yes
#else
    #warning TRACE_FACILITY no
#endif

You should see the same pattern of yes/no for every module compiled, especially main.c and BufferAllocation_2.c.

Make also sure that there is only a single copy of FreeRTOSConfig.h within the entire project.

kat123 wrote on Wednesday, February 28, 2018:

I can only see one copy of FreeRTOSConfig.h

Trace_facility comes up as no for everything except freertos.c, main.c and stm32f4xx_it.c

kat123 wrote on Wednesday, February 28, 2018:

//main.c

#include "main.h"
#include "stm32f4xx_hal.h"
#include "cmsis_os.h"

I haven’t added any of my own files, I generated code with STM32CubeMX and then added the FreeRTOS+TCP files to the project - should I be including the FreeRTOS files in main.c?

kat123 wrote on Wednesday, February 28, 2018:

I found a second FreeRTOSConfig.h in my files that wasn’t included in the project and removed it but thats created linker errors with BufferAllocation_2.c

heinbali01 wrote on Wednesday, February 28, 2018:

Trace_facility comes up as no for everything except … main.c

So when main.c is seeing include/FreeRTOS.h the structure xSTATIC_QUEUE is smaller than it is for other source files.

typedef struct xSTATIC_QUEUE
{
    ...
    #if ( configUSE_TRACE_FACILITY == 1 )
        UBaseType_t uxDummy8;
        uint8_t ucDummy9;
    #endif
};

And it looks like the compiler is warning about this.

Now you should check why main.c and stm32f4xx_it.c do not see that configUSE_TRACE_FACILITY is not defined.