Undefined static function
John L. Beal
beal at polaris.UUCP
Thu Sep 19 03:51:27 AEST 1985
> 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: <UK>!ukc!{hwcs,kcl-cs,ucl-cs,edcaad}!cstvax!fdc
> JANET: fdc at UK.AC.ed.cstvax or fdc at 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: <UK>!ukc!{hwcs,kcl-cs,ucl-cs,edcaad}!cstvax!fdc
> JANET: fdc at UK.AC.ed.cstvax or fdc at 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?
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list