I am writing a bootloader in C11. When the bootloader needs to transfer the control to the firmware, it reads a function pointer at a predefined memory address and calls it. The
_Noreturn
in C11 can only be applied to function definitions or declarations. The fact that the function doesn't return is not part of the prototype, unfortunately.
Since you seem to have gcc you could use an extension
typedef struct
{
uint32_t stackPointer;
__attribute__((__noreturn__)) FirmwareBootFn* programCounter;
}
FirmwareBootControl;
to mark the function pointer as not returning. Unfortunately though, there doesn't seem to be a way to ensure that the function that you assign to that really has that property by syntax, allone.