Pass queue to another c file

Hello,

Hello,
I’m trying to send events from different modules of my application to the main application manager. For example: adc module will send an event to app_manager_task if adc > 6V.

The obvious way is to use queues and my initial implementation is summarized below :

main.c file

#include "battery.h"

xQueueHandle app_queue ;

void main(void)
{
      app_queue  = xQueueCreate(10, sizeof(e_app_events));

      battery_init( &app_queue );
}

battery.c file


static xQueueHandle app_queue = NULL;

int battery_init(xQueueHandle* px_queue)
{
      *app_queue = px_queue;
}

When compiling, I’m getting this error

error: dereferencing pointer to incomplete type 'struct QueueDefinition'

Can you please advice how to do this efficiently ?

Just use the queue handle as is and pass it by value. There is no need for address operator nor pointers.

Just as hs2@ said, no need to use pointers:

#include "battery.h"

xQueueHandle app_queue ;

void main(void)
{
      app_queue  = xQueueCreate(10, sizeof(e_app_events));

      battery_init( app_queue );
}
static xQueueHandle app_queue = NULL;

int battery_init(xQueueHandle x_queue)
{
      app_queue = x_queue;
}

Indeed. This worked fine. Thx