karl@haddock.ima.isc.com (Karl Heuer) (06/13/89)
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 <varargs.h> in K&R1.)
diamond@diamond.csl.sony.junet (Norman Diamond) (06/14/89)
In article <13676@haddock.ima.isc.com> The Walking Lint stumbles: >... is one of the two contradictions in K&R1.$ >Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint >$ The other is that variadic functions are not permitted, yet printf() exists. This is not a contradiction. The authors stated (correctly, since ANSI wasn't yet the approved standard), that there was no portable way of implementing printf() in C. Most early (pre- final approval of ANSI) implementations of printf() were either done portably in some other language such as assembly, or done non-portably in C, or perhaps even non-portably in assembly. I believe that the only internal contradictions in K&R-I relate to whether an omitted storage class is equivalent to "extern" in certain cases, and to the possible meanings of each of these cases. -- Norman Diamond, Sony Computer Science Lab (diamond%csl.sony.co.jp@relay.cs.net) The above opinions are my own. However, if you see this at Waterloo, Stanford, or Anterior, then their administrators must have approved of these opinions.
karl@haddock.ima.isc.com (Karl Heuer) (06/16/89)
>>The other [contradiction] is that variadic functions are not permitted, yet >>printf() exists. > >This is not a contradiction. The authors stated [that printf() couldn't be >portably written in C] Well, maybe "botch" is a better word than "contradiction". I was quoting what Dennis Ritchie said parenthetically in his posting to comp.std.c a bit ago, when he was giving his opinion of the new C. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint