Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site gumby.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!uwvax!gumby!g-frank From: g-frank@gumby.UUCP Newsgroups: net.lang.c Subject: Re: static functions Message-ID: <299@gumby.UUCP> Date: Tue, 19-Feb-85 17:13:26 EST Article-I.D.: gumby.299 Posted: Tue Feb 19 17:13:26 1985 Date-Received: Thu, 21-Feb-85 05:32:01 EST References: <4903@ucbvax.ARPA> Organization: U of Wisconsin CS Dept Lines: 29 > 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.