Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!gatech!mcnc!decvax!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: declaration of functions Message-ID: <13676@haddock.ima.isc.com> Date: 12 Jun 89 20:13:49 GMT References: <4400001@tdpvax> <14726@duke.cs.duke.edu> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 27 In article <14726@duke.cs.duke.edu> apte@helios.UUCP (Jitendra Apte) writes: >In article <4400001@tdpvax> scott@tdpvax.UUCP writes: >> extern char *foo(); >> char *foo(); >>They seem to be equivalent and I have found no mention in K&R. They are equivalent. And it makes no difference whether the function is declared in a different file, or later in the same file%. >[Quotes from K&R1] >"At most one sc-specifier may be given in a declaration. If the sc-specifier >is missing from a declaration, it is taken to be `auto' inside a function, >`extern' outside. Exception : functions are never automatic". Although this reaches the right conclusion in this case (since the declaration is for a function), it should be noted that this clause is not quite correct in general, since it would imply that "int x;" and "extern int x;" are also equivalent. Elsewhere in K&R1, it is stated that shared globals must be declared with the "extern" keyword in N-1 files and without "extern" in exactly one file. This is one of the two contradictions in K&R1.$ Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint ________ % As long as it's global. Forward declarations of static functions must use the keyword "static". $ The other is that variadic functions are not permitted, yet printf() exists. (There is no mention of in K&R1.)