"static" keyword used with function names

ORCUTT at cc.utah.edu ORCUTT at cc.utah.edu
Tue Jul 24 13:37:08 AEST 1990


I have a question about the incarnation of the "static" keyword
that tells C that a function or variable name is only visible in
the current file.  If I write

static int func(void);     /* A declaration */

.
.
.

static int func(void)      /* A definition */
{
/* do something */
return something;
}

H & S have a passage that seems to say that the "static" on
the declaration is illegal.  If I omit it, however, it would seem
that the function would be defaulted to type "extern" and then
the definition of type "static" would conflict with the declaration.
My Turbo-C and MSC compilers seem to allow the "static" in the 
delcaration, but my Metaware compiler complains.  So, how do
I correctly declare a function name "static" if I want
to declare the name earlier in the file that its definition?



More information about the Comp.std.c mailing list