Path: utzoo!attcan!uunet!husc6!mailrus!nrl-cmf!cmcl2!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: Passing types to a subroutine Message-ID: <8892@smoke.BRL.MIL> Date: 15 Nov 88 06:33:28 GMT References: <14457@mimsy.UUCP> <8853@smoke.BRL.MIL> <14548@mimsy.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 21 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. The technique I suggested will work, although you might be better off with separate functions to operate on different data types. >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? Any pointer type can be cast to either pointer-to-char or (if you have it) pointer-to-void as a "canonical" pointer type to be passed through a function parameter knothole having definite type, and inside the function the conversion can be done in the reverse direction. You need to have additional information as to which type to convert back to; this bit of information can be passed via another parameter. If you can figure out how to avoid having a function with such a messy interface, you'd be better off.