I am trying indirectly accessing a static function using function pointer within a program. , I've encountered errors that I'm struggling to resolve.
main.c
Code:
#include<stdio.h>
void (*fp)();
static void foo()
{
printf("Welcome \n");
}
int main()
{
fp = &foo;
return 0;
}
file1.c
Code:
extern void (*fp)();
fp();
Output
Code:
file1.c:3:1: warning: data definition has no type or storage class fp();
^~
file1.c:3:1: warning: type defaults to 'int' in declaration of 'fp' [-Wimplicit-int]
file1.c:3:1: error: 'fp' redeclared as different kind of symbol
file1.c:1:15: note: previous declaration of 'fp' was here
extern void (*fp)();