Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!pacbell.com!ames!sgi!shinobu!fido.wpd.sgi.com!bh From: bh@sgi.com (Bent Hagemark) Newsgroups: comp.sys.sgi Subject: Re: R2000 stack alignment question Message-ID: <1991May30.200122.15985@fido.wpd.sgi.com> Date: 30 May 91 20:01:22 GMT References: <9105281723.AA11513@crow.omni.co> Sender: news@fido.wpd.sgi.com (Usenet News Admin) Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 25 In article <9105281723.AA11513@crow.omni.co> rpaul@crow.UUCP (Rodian Paul) writes: >> After some hours of digging through assembly code I've finally found out >> that varargs.h depends on the stack being aligned to an 8-byte boundary, >> and the C compiler does its utmost to keep it like that (unlike me). >> >Don't use varargs(5) it is non-standard, use stdarg(5) instead if you want >portabilty via ANSI C. Absolutely (use stdarg(5)). The following is from the 4.0 stdarg(5) man page: The va_start (ap, ParmN) macro initializes ap for subsequent use by va_arg and va_end. va_start must be called before any use of va_arg. * The ANSI C Standard (ANSI X3.159-1989) restricts the type of parmN to one * of the types resulting from the default argument promotions, currently * int, unsigned int, pointer, or double. If va_start is invoked with a * parmN which is not one of these types (e.g., if parmN is short or char) * the behavior is undefined. After learing this the hard way I asked that the *'ed lines be added to the stdarg(5) man page. The default argument promotion rules are described in section 2.7 of K&R C, 2nd Edition. Bent