#include <stdio.h>
#include <string.h>
void func1 (void) { printf( "1\n" ); }
void func0 (void) { printf( "0\n" ); }
typedef struct {
void (*func0)(void);
void (*func1)(void);
}mainJT;
static const mainJT coreJT = {
core_func0,
core_func1
};
mainJT currJT;
int main()
{
currJT=coreJT;
coreJT.core_func0();
getchar();
return 0;
}
Please help me fix the errors, I am sure I am making some obvious mistakes. Thanks.
Your question isn’t quite clear but I see what I can find.
Here you are declaring a struct with function pointer members
func0andfunc1. Then you are trying to define acoreJTvariable via an initializer list:But this doesn’t work, because there are no functions called
core_func0orcore_func1!Also you try to call
which is also incorrect since your struct doesn’t have a member of name
core_func0.For a possible solution try renaming your functions like so:
and call your function pointer by