# Pass queue to another c file

**URL:** <https://forums.freertos.org/t/pass-queue-to-another-c-file/15608>\
**Category:** Kernel\
**Tags:** debug\
**Created:** [August 9, 2022, 7:08am UTC](https://forums.freertos.org/t/pass-queue-to-another-c-file/15608 "2022-08-09T07:08:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hiham](https://avatars.discourse-cdn.com/v4/letter/h/7ab992/32.png) [@Hiham](https://forums.freertos.org/u/Hiham)\
**Post date:** [August 9, 2022, 7:08am UTC](https://forums.freertos.org/t/pass-queue-to-another-c-file/15608/1 "2022-08-09T07:08:32Z")

</div>

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

```auto
#include "battery.h"

xQueueHandle app_queue ;

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

      battery_init( &app_queue );
}

```

**battery.c** file

```auto

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 ?

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [August 9, 2022, 7:21am UTC](https://forums.freertos.org/t/pass-queue-to-another-c-file/15608/2 "2022-08-09T07:21:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [August 9, 2022, 8:42am UTC](https://forums.freertos.org/t/pass-queue-to-another-c-file/15608/3 "2022-08-09T08:42:13Z")

</div>

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

```auto
#include "battery.h"

xQueueHandle app_queue ;

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

      battery_init( app_queue );
}

```

```auto
static xQueueHandle app_queue = NULL;

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

```

---

<div class="post-metadata">

**Author:** ![Hiham](https://avatars.discourse-cdn.com/v4/letter/h/7ab992/32.png) [@Hiham](https://forums.freertos.org/u/Hiham)\
**Post date:** [August 9, 2022, 11:52am UTC](https://forums.freertos.org/t/pass-queue-to-another-c-file/15608/4 "2022-08-09T11:52:09Z")

</div>

Indeed. This worked fine. Thx
