Passing types to a subroutine
Stephen J. Roznowski
sjr at mimsy.UUCP
Tue Nov 15 08:55:37 AEST 1988
In article <8853 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
>In article <14457 at mimsy.UUCP> sjr at 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 at mimsy.umd.edu
More information about the Comp.lang.c
mailing list