function pointer does not call a function in CW 5.0

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

function pointer does not call a function in CW 5.0

Jump to solution
1,720 Views
FC
Contributor III
Hi,
 
Under CW 5.0, I have declared a simple function pointer:
 
void (*fp) ();
 
the call:
 
fp = &MCU_init;  // just an example
 
In simulation,  fp = the address of MCU_init, but does not execute the function.
I am using the small memory model.  I also used a typedef, but still no luck. 
 
Is it a compiler setting?
Labels (1)
Tags (1)
0 Kudos
1 Solution
344 Views
CrasyCat
Specialist III

Hello

How are you calling the function?

fp = &MCU_init; will only initialize fp with the address of function MCU_init.

To call the function you have to write

fp();

CrasyCat

View solution in original post

0 Kudos
2 Replies
345 Views
CrasyCat
Specialist III

Hello

How are you calling the function?

fp = &MCU_init; will only initialize fp with the address of function MCU_init.

To call the function you have to write

fp();

CrasyCat

0 Kudos
344 Views
FC
Contributor III
Thanks
Forgot about the call.
 
Besides using function pointers in a table, what other practical uses are there?
0 Kudos