In the C language, the usual route for function pointers as callbacks from some library is to include a void*
pointer for the context of the user:
v
Assuming you wish to allocate the actual function code, rather than the function pointer. The way this is done when writing bootloaders and similar:
#pragma __declspec __attribute__
blabla with sugar on top. Highly compiler-specific.uint8_t func [n]
array, containing the raw OP codes in hex.((func_ptr)func) ()
.As you hopefully can tell, this can be quite a task, depending on system. For small microcontrollers using embedded systems compilers, it is somewhat easily achievable. For more intricate systems like x86 or PowerPC, using compilers like gcc, far less so. You'll be relying on various poorly-specified behavior and the code will be completely system-specific.