James S. Singleton wrote:
On Wed, 01 Feb 2006 02:23:41 -0800, Vladimir S. Oka wrote:
Umesh wrote: What is the use by making function Static.
Short answer: static functions are invisible to the other compilation
units. This means you're allowed to re-use the same function names in
other source files, and the linker won't balk at you.
I'm sure there's a more precise way of saying the above.
Maybe not more precise, but certainly simpler: A function F labeled
static can only be used by functions defined in the same file as F.
/referenced by name/, not /used/:
File A:
void user( void (*arg)(void) ) { arg(); }
File B:
#include <stdio.h>
extern void user( int (*arg)(void) );
static void used() { printf( ">> 'used' called\n" ); }
int main(void)
{
user( used );
return 0;
}
A uses `used` (it calls it). It cannot refer to it by name.
--
Chris "understanding is a three-edged sword" Dollin