Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site rtp47.UUCP Path: utzoo!linus!philabs!prls!amdimage!amdcad!decwrl!decvax!mcnc!rti-sel!rtp47!smithrd From: smithrd@rtp47.UUCP (Randy D. Smith) Newsgroups: net.unix-wizards,net.lang.c Subject: Re: variable number of arguments Message-ID: <127@rtp47.UUCP> Date: Thu, 8-Aug-85 07:31:32 EDT Article-I.D.: rtp47.127 Posted: Thu Aug 8 07:31:32 1985 Date-Received: Mon, 12-Aug-85 06:54:24 EDT References: <159@mips.UUCP> Reply-To: smithrd@rtp47.UUCP (Randy D. Smith) Distribution: net Organization: Data General, RTP, NC Lines: 29 Keywords: varargs portability Xref: linus net.unix-wizards:11494 net.lang.c:5457 Summary: Use it! In article <159@mips.UUCP> sah@mips.UUCP (Steve Hanson) writes: >One practice in C that is both deeply ingrained in UNIX (e.g. printf, doprnt.c) >and non-obvious to the reader are functions that take a variable number. [of arguments] > >My questions are: > (1) Are these macros being used by developers ? Yep. > (2) What is the reaction to them ? It works. The other way doesn't on many implementations. > (3) Is old code modified to use them? Yes. In particular, I've modified dbx (the 4.2 BSD debugger) to use varargs with complete success. I also modified ctrace (a Sys. V Rel. 2 debugging utility) to use varargs instead of passing a single argument of whatever type on the calling side, and expecting a "union { all possible types }" on the called side. GAK! I encourage more people to check out the man page for the varargs package, and to actually use it. IN PARTICULAR, if you have ever tried running some arbitrary piece of code on a UNIX (tm of AT&T Bell Labs) or UNIX-lookalike, had the code to break, then determined that the UNIX you are using "grows the stack in the ``wrong'' direction", then consider complaining to the bozo that wrote the non-portable code rather than considering the UNIX to be brain damaged. -- Randy D. Smith (919) 248-6136 Data General, Research Triangle Park, NC!mcnc!rti-sel!rtp47!smithrd