dave@unicom.UUCP (02/18/85)
From: dual!unicom!dave (David W. Vezie) What does it mean when you declare a function as: static char * func () .... I've always wondered about that. David W. Vezie College of Marin, Kentfield CA {dual|hplabs}!unicom!dave
ag4@pucc-h (Angus Greiswald the fourth) (02/19/85)
> What does it mean when you declare a function as: > static char * > func () > .... Unfortunately, all it means is that func() will be unknown outside the file in which it's declared. -- Jeff Lewis vvvvvvvvvvvv {decvax | hao | cbosgd | masscomp | uiucdcs | sequent | ihnp4}!pur-ee!lewie ^^^^^^^^^^^^
g-frank@gumby.UUCP (02/20/85)
> What does it mean when you declare a function as: > > static char * > func () > .... > It means that the name of the function is not visible outside the source file in which it was defined. This is very useful for restricting the scope of function names, which are by default visible everywhere, just like variables declared outside any function. So, if you want every compiland to have its own function called "error_handler," for example, just declare error_handler static every time you define it (in different files, obviously), and you won't have to worry about name scope (unless you want to). By the way, this same trick goes for variables declared outside of functions. They are obviously static, but by default their names are known globally. If you want statics global within an entire source file, but not visible outside, just declare them "static" explicitly, and their scope will be restricted to the file in which they are declared. -- Dan Frank Q: What's the difference between an Apple MacIntosh and an Etch-A-Sketch? A: You don't have to shake the Mac to clear the screen.
gwyn@Brl-Vld.ARPA (VLD/VMB) (02/21/85)
static char * func() ... means that func() returns a value of type (char *), and is "file-static", i.e. local to the source file and not available for linking with references from other files. This nicely encapsulates the name "func" so that it cannot conflict with the same name in other object modules.