Can't get vApplicationGetTimerTaskMemory to be recognised

I have #defined configSUPPORT_STATIC_ALLOCATION as 1, and so I need to define my own versions of vApplicationGetTimerTaskMemory() and vApplicationGetIdleTaskMemory().

Now, if I don’t do that, and try to build, then I get two linker errors, saying that those two functions are undefined. Of course.

If I define those functions, then vApplicationGetIdleTaskMemory() seems to be recognised by the linker, but I still get the error: Undefined reference to ‘vApplicationGetTimerTaskMemory’.

I have carefully checked the function to make sure it matches the prototype found in timers.h. The prototype there is:

    void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
                                         StackType_t ** ppxTimerTaskStackBuffer,
                                         uint32_t * pulTimerTaskStackSize );

My function is:

void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer,
                                     StackType_t  **ppxTimerTaskStackBuffer,
                                     uint32_t      *puxTimerTaskStackSize )
    static StaticTask_t xTimerTaskTCB;
    static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
    *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
    *ppxTimerTaskStackBuffer = uxTimerTaskStack;
    *puxTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;

What am I doing wrong?

Hi @Rocketmagnet
Welcome to the FreeRTOS Community Forums !
Is configUSE_TIMERS defined in your FreeRTOSConfig.h file?
configUSE_TIMERS should also be set to 1 for the timer APIs like ‘vApplicationGetTimerTaskMemory’.

Also you can instead set configKERNEL_PROVIDED_STATIC_MEMORY to 1 in the FreeRTOSConfig.h to use the kernel provided default implementations of these callbacks.

could it be that your callbacks are implemented in a cpp file and thus decorated by the compiler? If so, relocate them to a file with the extension .c (easiest solution).

Good call. Yes, I’ll try this. Strange though that vApplicationGetIdleTaskMemory() works but vApplicationGetTimerTaskMemory() doesn’t.

Hmm. Just noticed that I’d #included “task.h” but not “timers.h”.

When I #included “timers.h” the build worked! Strange, you’d think it wouldn’t because of the decoration.

possibly there is an implied

extern “C”

around the prototype which will disable decoration.

Yes, the timer file pre-declares the prototype of the function, and that includes the extern “C” part, so if the prototype declaration has been seen, the function will get the right linkage.

Thanks for taking the time to report back! It greatly helps other users.