Passing types to a subroutine

Henry Spencer henry at utzoo.uucp
Wed Nov 16 03:20:12 AEST 1988


In article <14548 at mimsy.UUCP> sjr at mimsy.umd.edu.UUCP (Stephen J. Roznowski) writes:
>The problem is that I can't determine the array type
>at compile time.  These subroutines are going to be part of
>a library.

In C, and on virtually all current machines, you *have* to determine the
array type at compile time, somehow, because the machine uses different
instructions to manipulate the different types.  The best you can do, on
the hardware level, is to have the code choose between several different
(pre-chosen, compiled-in) alternatives based on some indication of
what the type is for a particular invocation.  You'll have to pass in
some sort of type code, plus a pointer to the object (cast to "void *"
to standardize its representation), and then the code will have to look
at the type code, re-cast the pointer to the type it wants, and proceed.
-- 
Sendmail is a bug,             |     Henry Spencer at U of Toronto Zoology
not a feature.                 | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list