Path: utzoo!attcan!uunet!husc6!mailrus!cwjcc!hal!nic.MR.NET!tank!mimsy!sjr From: sjr@mimsy.UUCP (Stephen J. Roznowski) Newsgroups: comp.lang.c Subject: Re: Passing types to a subroutine Message-ID: <14548@mimsy.UUCP> Date: 14 Nov 88 22:55:37 GMT References: <14457@mimsy.UUCP> <8853@smoke.BRL.MIL> Reply-To: sjr@mimsy.umd.edu.UUCP (Stephen J. Roznowski) Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 35 In article <8853@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes: >In article <14457@mimsy.UUCP> sjr@mimsy.UUCP (Stephen J. Roznowski) writes: >>How do you pass the knowledge of the array type to the >>subroutine? > >You don't. Types are dealt with at compile time, not run time. >It is in fact possible for a pointer-to-float to be passed >differently than a pointer-to-double. > >If you REALLY have to do this, consider casting the arguments >(which should be "a", not "a[100]") to type pointer-to-void or >pointer-to-char, and add another parameter to the subroutine >that can be used to indicate how to "un-cast" the funny >parameter. The code for this won't be clean.. The problem is that I can't determine the array type at compile time. These subroutines are going to be part of a library. And you are right that the pointers may be different, or at least have different alignment properties. Is this true of the pointer-to-void or pointer-to-char? Stephen [Let's make inews happy, by adding lines] [This is worst than the line eater.] -- Stephen J. Roznowski sjr@mimsy.umd.edu