Function Pointer

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Function Pointer

跳至解决方案
1,642 次查看
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 解答
977 次查看
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 回复
978 次查看
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 项奖励
回复