Function Pointer

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
1,660件の閲覧回数
Skippy
Contributor II

I am working on  a small cooperative scheduler for a 9s08 project. The scheduler dynamically fills an array of structures with information for each task to be run by the scheduler. One of the pieces of data is a function pointer to the target task.  The function pointer definition in the struct looks like this:    unsigned int (*pTask)();

The complier (CW Dev Studio V6.2) does not emit a peep during compile/link.  But, when running debug on the hardware and stepping through the function that is supposed to pickup the functional pointer and launch the function we investigate the structure at the point where the code picks up the pointer and see:  "undefined function () returning unisgned int.  Should the functional pointer in the struct be declared as a __far since the target function is not in the local data area?  Any help would be appreciated. Thanks in advance.

ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
995件の閲覧回数
Skippy
Contributor II

Thought I'd share this... 

Definition of the function pointer as a struct member:

typdef  ABC_T

{

    void (*pTaskName)(void);

    .

    .

}astruct_t;

  

Then, calling the function:

 

(*astruct_t[Index].pTask)(); 

 

 

元の投稿で解決策を見る

0 件の賞賛
返信
1 返信
996件の閲覧回数
Skippy
Contributor II

Thought I'd share this... 

Definition of the function pointer as a struct member:

typdef  ABC_T

{

    void (*pTaskName)(void);

    .

    .

}astruct_t;

  

Then, calling the function:

 

(*astruct_t[Index].pTask)(); 

 

 

0 件の賞賛
返信