Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site polaris.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!bbnccv!bbncca!linus!philabs!polaris!beal From: beal@polaris.UUCP (John L. Beal) Newsgroups: net.lang.c,net.bugs.4bsd Subject: Re: Undefined static function Message-ID: <177@polaris.UUCP> Date: Wed, 18-Sep-85 13:51:27 EDT Article-I.D.: polaris.177 Posted: Wed Sep 18 13:51:27 1985 Date-Received: Sat, 21-Sep-85 05:00:45 EDT References: <297@cstvax.UUCP> Organization: IBM Research, Yorktown Heights, N.Y. Lines: 51 Xref: watmath net.lang.c:6484 net.bugs.4bsd:1762 > Here's a question for all the C language lawyers out there. What should > a C compiler make of the following: > > static char *tgoto(); > > main() > { > ..... > if (tgoto(......)..... > ..... > } > > In other words, we declare a function to be static, use it, but do not > define it in the source file. This occurs in libcurses/cr_tty.c (4.2BSD). > The 4.2 compiler happily accepts this and links the 'static' tgoto to a > definition in another source file. In this case it is what the author > intended, but it should really have been thrown out by the compiler, > methinks. > -- > Frank Cringle, Dept. of Computer Science, Univ. of Edinburgh > UUCP:!ukc!{hwcs,kcl-cs,ucl-cs,edcaad}!cstvax!fdc > JANET: fdc@UK.AC.ed.cstvax or fdc@UK.AC.ed.ecsvax From postnews Wed Sep 18 13:49:21 1985 > > static char *tgoto(); > > main() > { > ..... > if (tgoto(......)..... > ..... > } > > In other words, we declare a function to be static, use it, but do not > define it in the source file. This occurs in libcurses/cr_tty.c (4.2BSD). > The 4.2 compiler happily accepts this and links the 'static' tgoto to a > definition in another source file. In this case it is what the author > intended, but it should really have been thrown out by the compiler, > methinks. > -- > Frank Cringle, Dept. of Computer Science, Univ. of Edinburgh > UUCP: !ukc!{hwcs,kcl-cs,ucl-cs,edcaad}!cstvax!fdc > JANET: fdc@UK.AC.ed.cstvax or fdc@UK.AC.ed.ecsvax Who knows. C knows that functions are extern (K&R says that somewhere) so that a i char f(); will be extern. Maybe it just ignores that static in some implementations and believes it in others?