Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Passing types to a subroutine Message-ID: <1988Nov15.172012.19661@utzoo.uucp> Organization: U of Toronto Zoology References: <14457@mimsy.UUCP> <8853@smoke.BRL.MIL> <14548@mimsy.UUCP> Date: Tue, 15 Nov 88 17:20:12 GMT In article <14548@mimsy.UUCP> sjr@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@zoo.toronto.edu