I am working with the xinu embedded system in c. I created a new header file and declared a structure:
struct callout {
uint32 time;
void *funcaddr;
void *argp;
uint32 cid;
char *sample;
};
Basically, I am trying to declare a struct object and a funcaddr function for a function.
void test();
process main(void) {
struct callout *coptr;
coptr->sample ="hellowolrd";
coptr->funcaddr = &test;
(coptr->funcaddr)(coptr->argp);
kprintf("coptr %s \n", coptr->sample);
return OK;
}
void test() {
kprintf("this is the test function \n");
}
I try to call a function pointer through a structure, but I get an error: main.c: 30: 19: error: the called object is not a function or function pointer (Coptr-> funcaddr) ();
Please show what is the correct syntax for calling a function pointer.
source
share