Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!cbatt!cwruecmp!hal!ncoast!allbery From: allbery@ncoast.UUCP Newsgroups: comp.lang.c Subject: varargs (was Re: Public Domain _doprnt in C) Message-ID: <2321@ncoast.UUCP> Date: Tue, 7-Apr-87 20:51:18 EST Article-I.D.: ncoast.2321 Posted: Tue Apr 7 20:51:18 1987 Date-Received: Sat, 11-Apr-87 05:20:14 EST References: <938@copper.TEK.COM> <100@asi.UUCP> <2285@ncoast.UUCP> <6152@mimsy.UUCP> Reply-To: allbery@ncoast.UUCP (Brandon Allbery) Followup-To: comp.lang.c Organization: Cleveland Public Access UN*X, Cleveland, Oh Lines: 55 As quoted from <6152@mimsy.UUCP> by chris@mimsy.UUCP (Chris Torek): +--------------- | In article <2285@ncoast.UUCP> allbery@ncoast.UUCP (Brandon Allbery) writes: | >Note that varargs is defined such that it will work even on machines such as | >the Pyramid which pass arguments in registers (common on RISC machines). | | Or on the MIPS machines. +--------------- All I know about the MIPS machines is that Plexus supposedly makes one of them (Plexus calls it the P/95, I think; no idea what MIPS calls it or what archi- tecture it uses, but it's Plexus's only BSD machine. Sigh.) +--------------- | >You MUST declare only one argument -- va_alist -- and include the type of it | >as "va_dcl" without a semicolon. | | The reason I mention this is that in fact, on the Pyramid, Sun, | and Vax (all implementations of which I am aware), usages such as | that above in fact work. I wonder, then, if this has been guaranteed | anywhere. Has it? (I know, I should dig out a copy of the X3J11 | draft....) +--------------- Dunno about X3J11, POSIX, /usr/group, etc., but the System V.2 docs state that varargs must be used with va_alist as the ONLY argument. Sure, it works on stack machines where typecasting is mostly size changing or punning; but the va_alist-only stuff is the only way to be compatible with all machines. +--------------- | >(C compilers can then recognize this directly to do any special | >processing needed, as for the Pyramid.) | | Actually, Pyramid manages it without compiler hooks. I believe | MIPS uses compiler hooks, though. +--------------- I've never used a Pyramid, so I was guessing. However, it makes sense that varargs should be set up so a compiler can recognize va_alist etc. as tokens and generate the appropriate code. I would guess that some architectures might still not work; the ANSI C standard would fix this by allowing the function's varargs status to be pre-declared. (I hope; I know it was under consideration once, but varargs might not be supported in a pre-declaration in the current version of P1003.1.) ++Brando -- ____ ______________ / \ / __ __ __ \ Brandon S. Allbery | QUOTE OF THE DAY: ___ | /__> / \ / \ aXcess Company | / \ | | `--, `--, 6615 Center St. #A1-105 | ` | | \__/ \__/ \__/ Mentor, OH 44060-4101 | \____/ \______________/ +1 216 974 9210 | cbatt!cwruecmp!ncoast!allbery ncoast!allbery%case.CSNET@relay.CS.NET BALLBERY (UUCP) (CSNET/Internet) (MCIMail)