Path: utzoo!utgpu!watserv1!watmath!att!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!think.com!paperboy!meissner From: meissner@osf.org (Michael Meissner) Newsgroups: comp.std.c Subject: Re: Reality check (Was Re: prototypes required ?) Message-ID: Date: 22 Oct 90 17:59:44 GMT References: <1061@dg.dg.com> <1171@dms.UUCP> <14199@smoke.BRL.MIL> Sender: troot@OSF.ORG Organization: Open Software Foundation Lines: 48 In-reply-to: gwyn@smoke.BRL.MIL's message of 19 Oct 90 19:27:40 GMT In article <14199@smoke.BRL.MIL> gwyn@smoke.BRL.MIL (Doug Gwyn) writes: | In article <1171@dms.UUCP> albaugh@dms.UUCP (Mike Albaugh) writes: | > And neither will vast quantities of old code, which are used to | >"rolling their own" varargs routines. | | That never was a very wise practice, and was devised LONG AGO | to provide portable support for such situations. I lost track of how | many thousands of lines of other people's source code I have had to | change to use when porting to an environment different from | the model that they assumed when they "rolled their own" variable- | argument code. | | I expect most conforming implementations to also provide as | a convenience for their customers, although some may well require the | extra hooks that the standard provides and thus really not be able to | implement , only . With the MIPS standard calling sequence (also used in DECstations, and Silicon Graphics systems), there is one case that is impossible with varargs, but can be handled with stdarg. If the first argument is floating point, the MIPS calling sequence passes the number in a floating point register, otherwise it passes the first argument in integer registers. If the second argument was floating point and the first one was as well, it too is passed in a floating point register, otherwise it is passed in an integer register. The varargs stuff only works for arguments passed in integer registers. Because varargs functions don't tell the compiler anything in terms of a prototype, the compiler doesn't have a clue that it should really pass the floating point arguments in an integer register. The one thing that varargs can do which stdarg can't, is vary the type of the first parameter, since stdarg requires at least one non-varardic argument to hook into. In the ANSI meetings this was brought up and dismissed due to thinking the case was artifical, and that no real code actually dependend on it. Well we just found that one OS test suite does in fact depend on this, and only passes one argument to a varardic function, using other means to tell what type the argument is. In a similar vein, you can't have a stdarg function which takes zero or more arguments.... -- Michael Meissner email: meissner@osf.org phone: 617-621-8861 Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142 Do apple growers tell their kids money doesn't grow on bushes?