function pointer does not call a function in CW 5.0

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

function pointer does not call a function in CW 5.0

ソリューションへジャンプ
2,375件の閲覧回数
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?
ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
999件の閲覧回数
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 件の賞賛
返信
2 返答(返信)
1,000件の閲覧回数
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 件の賞賛
返信
999件の閲覧回数
FC
Contributor III
Thanks
Forgot about the call.
 
Besides using function pointers in a table, what other practical uses are there?
0 件の賞賛
返信