rkc@XN.LL.MIT.EDU (rkc) (06/10/89)
I know that many compilers permit functions that return full structures ie: more_than_4_byte_structure function(arg1,arg2) int arg1,arg2; ... but is it in the latest ansii standard draft, or will it be left as a compiler extension? E-Mail responses please. Thanks, -Rob
rex@aussie.UUCP (Rex Jaeschke) (06/13/89)
I know that many compilers permit functions that return full structures but is it in the latest ansii standard draft, or will it be left as a compiler extension? I recall the draft places no limits on the size of a structure or union that may be returned by value. Initially, that was true for passing by value also but was amended such that the max size that can be passed IN is implementation-defined. DEC's VAX C, for example, cannot pass in anything larger than 255 longwords (1020 bytes) since that's the limit on the size of a stack frame in the VAX Standard Calling sequence. However, that compiler places no limit on the returned object size. Rex ---------------------------------------------------------------------------- Rex Jaeschke | C Users Journal | Journal of C Language Translation (703) 860-0091 | DEC PROFESSIONAL |1810 Michael Faraday Drive, Suite 101 uunet!aussie!rex | Programmers Journal | Reston, Virginia 22090, USA ---------------------------------------------------------------------------- Convener of the Numerical C Extensions Group (NCEG) ----------------------------------------------------------------------------
gwyn@smoke.BRL.MIL (Doug Gwyn) (06/13/89)
In article <20.UUL1.3#5077@aussie.UUCP> rex@aussie.UUCP (Rex Jaeschke) writes: >DEC's VAX C, for example, cannot pass in anything larger than 255 longwords Strictly speaking, a C implementation on such a machine COULD pass an arbitrarily large amount of arguments, using a different design for function linkage than DEC chose. There are numerous architectural design botches that force a language implementor to avoid what the hardware architect thought would be helpful and instead to do things another way. For example, some models of the PDP-11 had a MARK instruction that was supposed to help with procedural language linkage, but I never found a good way to use it.
rex@aussie.UUCP (Rex Jaeschke) (06/14/89)
> In article <20.UUL1.3#5077@aussie.UUCP> rex@aussie.UUCP (Rex Jaeschke) writes: > >DEC's VAX C, for example, cannot pass in anything larger than 255 longwords > > Strictly speaking, a C implementation on such a machine COULD pass an > arbitrarily large amount of arguments, using a different design for > function linkage than DEC chose. You are quite correct Doug. As I recall when trying this on DEC's ULTRIX pcc several years ago, it allowed larger staructures to be passed. It passed them on the stack first and then called the function specifying one less argument than the programmer actually specified. The called function then picked that structure off the stack prior to the function call frame. I think the restriction was permitted by X3J11 at the request of DEC though but I think that's a bit of a red herring since VAX C "violates" the VAX Std Calling sequence in numerous other ways anyway. (Passing doubles by value, and strings as nul-terminated rather than as desciptors.) OK, DEC folks I know you have a special dispensation from the architecture group but I consider it a "violation." Rex ---------------------------------------------------------------------------- Rex Jaeschke | C Users Journal | Journal of C Language Translation (703) 860-0091 | DEC PROFESSIONAL |1810 Michael Faraday Drive, Suite 101 uunet!aussie!rex | Programmers Journal | Reston, Virginia 22090, USA ---------------------------------------------------------------------------- Convener of the Numerical C Extensions Group (NCEG) ----------------------------------------------------------------------------