I have microcontroler that I am working with. When debugging it is necessary to call a function from that is hard coded in ROM. Technical Reference shows how to do this:
# define Device_cal (void(*)(void))0x3D7C80
and calling procedure looks like this:
(*Device_cal)()
I can’t understand what actually happens here, so my question is:
How does it work?
The
#definecauses(*Device_cal)()to be expanded into this immediately before compiling:The
void(*)(void)is a declaration for a function pointer that takesvoidand returnsvoidtypes. The(*())represents a cast for the next token in the expression (0x3D7C80). Thus this asks to treat the data at location0x3D7C80as a function. The final()calls the function with no arguments.