Mail Archives: djgpp/1997/04/26/10:29:52
Bob Kematick (Bob AT ge DOT chem DOT binghamton DOT edu) wrote:
: Ruiter de M (mdruiter AT cs DOT vu DOT nl) wrote:
: : Ian Mausolus (mausolus AT ican DOT net) wrote:
: : : What is the significance of the word "static" in front of a function name
: : : in C?
: [ snip ]
: : That means, that the function is declared local to the file. No other file
: : can use it (by means of a .h-file).
: [ snip again]
: Nonsense.
[snipped example]
That's not what he meant. If file1.c contains a function and file2.c calls
it (having a suitable prototype) the linker will find the correct
function. However, if the function in file1.c is declared static, file2.c
is not allowed to use it; the linker will not find the function, and you
will get an error.
The point of the keyword is that if you have a function which is only used
internally to the .c file it is in and another .c file attempts to use a
symbol of the same name, an error will occur. Declaring the function
static will remove this error.
--
George Foot <mert0407 AT sable DOT ox DOT ac DOT uk>
Merton College, Oxford
- Raw text -