B
Bryan Parkoff
I created global variable for pointer to function. Set_pf() function is
to copy Test() function into global variable of pf(). The main() function
starts before Set_pf() function is executed. The Pointer_To_Function
variable copied into pf variable without any problem. pf() function has
memory address to have a pointer to function of Test() function. The
problem is that when Set_pf() function is exited before pf variable is set
to zero automatically that it is not supposed to do. Then, pf() function
inside main() function attempts to execute before crash occured with illegal
memory. Is there a way to fix to prevent pf() variable to set zero
automatically? Here is my source code below.
void (*pf)(void);
void Test(void)
{
int a = 5;
}
void Set_pf(void (*Pointer_To_Function)(void))
{
void (*pf)(void) = Pointer_To_Function;
pf(); // Execute is fine.
// Exit function to set zero to pf() variable. It is not supposed to do.
}
int main()
{
Set_pf(Test);
pf(); // Failed because of zero.
return 0;
}
Bryan Parkoff
to copy Test() function into global variable of pf(). The main() function
starts before Set_pf() function is executed. The Pointer_To_Function
variable copied into pf variable without any problem. pf() function has
memory address to have a pointer to function of Test() function. The
problem is that when Set_pf() function is exited before pf variable is set
to zero automatically that it is not supposed to do. Then, pf() function
inside main() function attempts to execute before crash occured with illegal
memory. Is there a way to fix to prevent pf() variable to set zero
automatically? Here is my source code below.
void (*pf)(void);
void Test(void)
{
int a = 5;
}
void Set_pf(void (*Pointer_To_Function)(void))
{
void (*pf)(void) = Pointer_To_Function;
pf(); // Execute is fine.
// Exit function to set zero to pf() variable. It is not supposed to do.
}
int main()
{
Set_pf(Test);
pf(); // Failed because of zero.
return 0;
}
Bryan Parkoff