"Malcolm McLean" <re*******@btinternet.comwrites:
"Ravi" <ra*********@gmail.comwrote in message
news:11**********************@m37g2000prh.googlegr oups.com...
>What is the difference between following function definitions:
static int f1()
{
/* code here */
}
and
int f1()
{
/* code here */
}
The function declared static can only be called from another function
within the same file. This is very useful in complex projects, because
it simplifies the connections between modules.
Actually, it means that the name is only visible within the same
translation unit (which, with #include directives, could consiste of
multiple files). If you take the address of f1, you can call it
indirectly from anywhere.
In most cases, you wouldn't want to do this; if you want to call it
from another translation unit, you don't make it static. But I can
think of cases where you'd want to be able to call a function
indirectly without making its name directly visible.
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"