Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ll-xn!mit-eddie!genrad!decvax!minow From: minow@decvax.UUCP (Martin Minow) Newsgroups: comp.lang.c Subject: ANSI C -- static forward references Message-ID: <108@decvax.UUCP> Date: Sun, 14-Dec-86 11:15:56 EST Article-I.D.: decvax.108 Posted: Sun Dec 14 11:15:56 1986 Date-Received: Tue, 16-Dec-86 02:14:41 EST Lines: 53 This is one of a collection of comments on the Draft Standard, posted to comp.lang.c for discussion before I mail a final draft to the Ansi C committee. Each message discusses one problem I have found with the Draft Standard that I feel warrants a "no" vote. Note that this message is my personal opinion, and does not reflect on the opinions of my employer. ---- Problem: Page 19, line 42, page 49, line 43, page 70, line 22. "static" should be permitted only for definitions. "extern" should be the only declarator that specifies external linkage (whether file or program). Page 19, line 42ff. The formulation as given here does not allow the common use of "extern" to forward reference a variable or function that is actually declared "static." This breaks existing programs with sequences such as the following: char * func() { extern char *subr(); ... return (subr()); } ... static char * subr() { ... } A subsequent definition should be allowed to declare an object or function "static," overriding the previous linkage specification. The storage class specifier "static" (section 3.5.1, page 49) should be permitted only on definitions. Page 70, line 22. As noted above, "static" should not be used to declare external functions with file scope. The module referring to the function] does not need to ``know'' that the actual function definition is in the same file -- indeed, it should not. If only "extern" were used to specify linkage, the programmer would be free to move function definitions between files as required by the application. In the current standard, the *user* of a function must know whether the function is defined in the current file. The only time this use of "static" would be useful would be to permit one-pass compilers to produce smaller code segments for function calls. Given the current direction of the computer industry, there is no need for such limitations. ---- Martin Minow decvax!minow