Hi, I know the types in FreeRTOS.h are meant to be used at our peril, but since they’re there, it would be nice if they’re consistent with the kernel definitions.
Specifically, xSTATIC_QUEUE is mostly right, except for:
void * pvDummy1[ 3 ];
meant to account for the first few pointer fields in queue.c:QueueDefinition, except that QueueDefinition only has 2 pointers before the union.
First, the “STATIC” types in FreeRTOS.h ARE meant to be used in user code, they are needed to statically allocate their corresponding objects. Errors of extra storage are less important, as it is just a slight waste of memory, but really shouldn’t be there.
I do wonder if it makes sense to add a “static_assert” in the code that defines the actual structures to confirm they are the same size. (If FreeRTOS doesn’t want to add the C11 dependency, there are ways to do it is prior versions, they just look worse.)
typedef struct SemaphoreData
{
TaskHandle_t xMutexHolder; // This is a pointer
UBaseType_t uxRecursiveCallCount;
} SemaphoreData_t;
Note that first member of both QueuePointers_t and SemaphoreData_t is a pointer. The definition in xSTATIC_QUEUE clubs pcHead, pcWriteTo and first members of QueuePointers_t and SemaphoreData_t together and then contains a union for second members of QueuePointers_t and SemaphoreData_t.