Hey all!
I define a function pointer (globally defined):
void myFunc( myStruct* ptrStruct );
and give it a default definition:
void myFunc( myStruct* ptrStruct )
{
diag("\nOriginal function called, override this!");
}
Now the function I want to actually call:
void myDesiredFunc( myStruct* ptrStruct )
{
diag("\nCorrect function called");
}
Here's where the issue comes in- I need to set my function pointer in an intermediary function that is part of the API I'm building:
void SetMyFunction( function* newfunc )
{
myFunc = (function*)newfunc;
}
myStruct myStructInstance;
in main()
{
...
SetMyFunction( myDesiredFunc );
myFunc( &myStructInstance );
...
}
But the original function definition is used.
The function pointer (myFunc) and structure pointer parameter are globally defined. I've tried several casts in the SetMyFunction function (i.e. function*, function, void*, etc.)
Anyone see what I'm missing? Do I need to somehow specify the parameter type in my cast; something like
myFunc = (function(myStruct*))newfunc; //??
Thanks so much for your time!