Pointer to pointer when passing parameter to xQueueSendToBack()

Hi,
the sample code from xQueueSendToBack() and also the one in xQueueSendToFront() shows the following code:

struct AMessage *pxMessage;

if( xQueue2 != 0 )
{
/* Send a pointer to a struct AMessage object.  Don't block if the
queue is already full. */
pxMessage = & xMessage;
xQueueSendToBack( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );
}

I don’t understand by the second argument is passed as “pointer to pointer”. Should it not just be passed the pointer pxMessage (i.e. without the & address-of operator)?

Thank you :slight_smile:

Look at how the Queue was created, it is queue of pointers to struct AMessage, not a Queue of struct AMessage.

We pass a pointer to what we want to ensue, so we pass a pointer to the pointer.

Of course…!!

Thank you Richard :slight_smile: