This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linker & #pragma WEAK() - can you override a function both called and defined in the same file?

Other Parts Discussed in Thread: HALCOGEN

We have a file that has lines of code like this:

#pragma WEAK(selftestFailNotification)
void selftestFailNotification(uint32 flag)
{

/* USER CODE BEGIN (1) */
/* USER CODE END */

}


.....

void ccmSelfCheck(void)
{
/* USER CODE BEGIN (3) */
/* USER CODE END */

......

    /* Check if there was an error during the self-test */
    if ((CCMSR & 0x1U) == 0x1U)
    {
        /* STE is set */
        selftestFailNotification(CCMSELFCHECK_FAIL1);
    }

All in the same file.

If the call to selftestFailNotification() and the function itself are in the same file -- my understanding is that the #pragma WEAK()

is useless from a standpoint of allowing the user to place a different selftestFailNotification() in their own file and overriding the empty on in this file...   because the linker doesn't break an .obj file down and link in parts of the .obj without linking in other parts.

Is that right?  (regarding linker behavior)    If so we'll need to put a ticket in on our software to correct this if it's supposed to allow the handler to be overridden...

See