I'm writing code for an embedded system. The compiler is a GCC derivative. Is the following code correct?
void *voidPointer = 0;
int (*functionPointer)(int a);
int testFunction(int a)
{
return(a+1);
}
void registerFunction(void *pvFunctionAddress)
{
voidPointer = pvFunctionAddress;
}
main()
{
...
registerFunction(testFunction);
functionPointer = voidPointer;
x = functionPointer(17);
...
}
Now x should have the value 18. The compiler does not show an error - but is this correct? Or do we overwrite some memory on the stack.
Thanks.