context of function portTASK_FUNCTION in sourecode of freeRTOS (void)pvParameters

755 views Asked by At

In tracing source code of task.c for freeRTOS, i see a function named portTASK_FUNCTION. its code is as below

static portTASK_FUNCTION( prvIdleTask, pvParameters )
{
    /* Stop warnings. */
    ( void ) pvParameters;  //<--what for??

    for( ;; )
    {
        do something
    }
}

i don't understand what ( void ) pvParameters means, hope someone could help me, thx

btw, this function's type of args are not declared, why does it can work?

2

There are 2 answers

1
maestro On BEST ANSWER

This code consists of comment:

/* Stop warnings. */

The optimizer will remove the code you mentioned. But there is unused parameter in function - pvParameters. And this code is written to shut up compiler. It does nothing.

1
Richard On

portTASK_FUNCTION is NOT a function, its a macro. If I google it the first link I get is here: http://www.freertos.org/implementing-a-FreeRTOS-task.html - in this case prvIdleTask is the function. In all but the one obscure case mentioned on the link the portTASK_FUNCTION macro is obsolete (not required) but is used in the main kernel code for portability.