Multiple Entry Points in C
COTTRELL, JAMES
cottrell at NBS-VMS.ARPA
Tue Nov 5 05:01:09 AEST 1985
/*
> I have a question that I hope some wizard can answer,
> with respect to achieving multiple function-entries in C.
> I know this is possible in Fortran; a module might look like:
>
> subroutine a(i,j)
> i = j/i
> entry b(i,j)
> i = i + j
> return
> end
>
> and the resulting assembly code would look something like this:
[Fortran ASM deleted. Boy was it UGLY!]
> But I am at a loss as to how to express this in C. Any hints
> or pointers [:-)] will be appreciated....
You cannot do this directly, but you can achieve the same effect by
specifying an extra arg specifying which entry you want. Then use it
in a switch statement to select the proper processing.
#define A 0
#define B 1
func(which,i,j) int which, i, j;
{ switch (which)
case A: i = j / i;
case B: i += j; /* use C notation */
}
}
When I figured this out I no longer craved multiple entry points, altho
I don't condemn them either. Information can be passed by way of the PC
as well as any general register, altho it seems more prone to abuse.
jim cottrell at nbs
*/
------
More information about the Comp.lang.c
mailing list