Structures

Chris Torek chris at mimsy.umd.edu
Wed Mar 7 19:42:12 AEST 1990


In article <MEISSNER.90Mar1163541 at curley.osf.org> meissner at osf.org
(Michael Meissner) writes:
>ANSI requires that implementations be able to pass structures by
>value, return them, and assigning structures.  Note that the maximum
>size of a structure that you can pass is implementation defined.  For
>example, unless they've changed the calling sequence recently, on a
>VAX, the size of all of the arguments must be less than 512 longwords
>(or bytes, I don't use vaxen).

This is true but misleading: the VAX can easily pass more than 255
longwords, but when it does so, the magic `pop this many longwords'
count (for the `ret' instruction) will be incorrect and the compiler
must compensate for this.  Some (non C) routines may also get confused
as to how many arguments were given.

>>[why did K&R-1 C not have structure valued arguments?]

>Possibly because the PDP11 did not have a block move instruction, or
>possibly Dennis Ritchie hadn't gotten around to it when K&R-I was
>written.

The latter seems the most likely explanation.  Things were added to the
orignal PDP-11 C compiler as they became useful; structure-valued
arguments were not often wanted.  This same C compiler did not have
a `long' data type in Version 6, for instance.  Fortunately, K&R 1st
edition was written after the `long' type was added.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list