Compiler bug
Herb Kanner
kanner at tymix.UUCP
Fri May 10 11:21:31 AEST 1985
In article <1136 at sjuvax.UUCP> jss at sjuvax.UUCP (J. Shapiro) writes:
>I recently noticed that the following will not compile correctly on a
>4.2 BSD system:
>
>extern int usr1(), usr2(), usr3();
>
>int usrprocs[] = { usr1, usr2, usr3 }
>
>whereas it compiles correctly on intel machines, cromix, and Aztec C.
>It seems to me that this is something the linker should be able to handle
>correctly, and therefore should not be a bug.
>
You want to use
extern int usr1(), usr2(), usr3();
int (*usrprocs[])() = { usr1, usr2, usr3 };
The call is written as (*usrprocs[i])() and can even have parameters, e.g.
(*usrprocs[i])(a, b, c) provided the number and types of the parameters are
identical for all three functions.
--
Herb Kanner
Tymnet, Inc.
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list