I have an function address stored in an unsigned int, and a function pointer.
Now i want that function_pointer will contain the value of function_address
unsigned int function_address = 0xdeadbeef;
void(*function_pointer)(void) = function_address; // not valid
how to do that in C ?
Perform an explicit cast.
void(*function_pointer)(void) = (void (*)(void))function_address;
Try this
typedef void(*function_pointer_type)(void)
function_pointer_type *function_pointer = (function_pointer_type *) address;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With