Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!pasteur!ames!lll-winken!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.lang.c Subject: Re: printf() problem Message-ID: <1520@auspex.auspex.com> Date: 1 May 89 19:57:21 GMT References: <163@marvin.moncam.co.uk> <1367@ndmath.UUCP> Reply-To: guy@auspex.auspex.com (Guy Harris) Organization: Auspex Systems, Santa Clara Lines: 24 >My question is if the stack-based method of passing arguments, or the >order in which the arguments are passed, is part of the C definition. No, it's not. >The alternative seems to me to be making all functions that take a >variable number of arguments non-portable. No, it's not. >Is this the case? No, it's not. If you use the "stdarg.h" mechanism in the (p)ANS, any (p)ANS-conforming compiler is obliged to perform whatever magic is necessary to make that mechanism work. If you use the "varargs.h" mechanism supported by many C implementations, the compiler is again supposed to perform whatever magic is necessary to make that mechanism work. However, if you take the address of one of the arguments and use it to step through the argument list yourself, you run the risk of having your code not work on some implementations - but then, that style of variable-number-of-arguments function isn't portable.