
Originally Posted by
vajra11
Thanks for making clear. A static function is accessible only within the file it is defined in. if we want to access from the another file then we have to make function extern
Or, declare a pointer to a function and initialize this pointer to the static function:
Code:
/* module1.c */
static int f( int x ) { return x + x; } // visible to this module only;
int (*fptr)(int) = f; // global extern ptr to function f;
Code:
/* module2.c */
extern int (*fptr)(int);
...
int main( void )
{
int a = fptr(2); // calling the module2.c static function, indirectly.
...
}