Path: utzoo!attcan!uunet!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!mips!gumby From: sah@gumby (Steve Hanson) Newsgroups: comp.sys.mips Subject: Re: Question on cc Message-ID: <40299@mips.mips.COM> Date: 20 Jul 90 15:50:42 GMT References: Sender: news@mips.COM Reply-To: sah@gumby (Steve Hanson) Organization: MIPS Computer Systems, Sunnyvale CA Lines: 59 In-reply-to: David.Steere@CS.CMU.EDU In article , David.Steere@CS writes: >BACKGROUND: > >I'm porting a file system to the Dec 3100. Our code is mostly written in >C++, which gets precompiled (as it were) into standard C. >The pmax C compiler is standard C (pcc), so for the most part, this >isn't a problem. > >However, we are having a problem with procedures with a variable >number of arguments (like printf). Typically, when such a procedure is >called, the parameters are read off the stack, using a pointer to the >first argument to reference the other arguments. This assumes that >the arguments are written to the stack. Syntactically, variable length >procedure headers can be declared by including , and having >the last argument be va_alist. varargs.h declares various macros >which basically handle the referencing to the stack. > >In the Pmax compiler, the first several arguments are not written onto >the stack automatically. So they are not found when the procedure is >called. It turns out that the compiler looks for the symbol "va_alist" in >the procedure header, and if it is found forces all the arguments to be >written to the stack. Okay, this seems like a hack and it seems to work >fine, except that we use C++, which during preprocessing renames all the >variables, prepending things like au0_ on the front of variable names. >So va_alist is now au0_va_alist. Since that isn't the same as va_alist, >the compiler does not force all the arguments to the stack. > >QUESTION: >Is there a way to tell the compiler to force arguments to the stack for >a >particular routine? > >thanks, > >david. Two suggestions: 1) Bypass the name problem by declaring these functions with ellipsis notation: void foo(int c, ...) {} and ask your translator to produce ANSI C syntax, e.g. /* <> */ CC +a1 foo.c 2) Use the native cpp to give you your name back, e.g. CC -Wp,-D__0va_alist=va_alist foo.c or in your case CC -Wp,-Dau0_va_alist=va_alist foo.c -- -- UUCP: {ames,decwrl,prls,pyramid}!mips!sah USPS: MIPS Computer Systems, 930 Arques Ave, Sunnyvale CA, 94086