Article View: gnu.gcc.help
Article #50931Seek help with va_start macro in stdarg.h porting from Apollo C
From: Emmett Mclean
Date: Wed, 28 Jul 1993 03:24
Date: Wed, 28 Jul 1993 03:24
75 lines
3485 bytes
3485 bytes
David,
I took a stab at compiling a package called MEM which was originally written
in portable C on an Apollo platform. All of the programs compile
nicely except support.c where the following occurs:
%make
gcc -c -DPOSH -DKANT -DDO_NOT_USE_PROTOTYPES -I../include -DSTATS -DVERBOSE support.c
In file included from /usr/local/lib/gcc-lib/vax-dec-ultrix4.3/2.4.5/include/stdio.h:2, from support.c:2:
../include/stdarg.h:11: warning: `va_start' redefined
/usr/local/lib/gcc-lib/vax-dec-ultrix4.3/2.4.5/include/varargs.h:86: warning: this is the location of the previous definition
../include/stdarg.h:12: warning: `va_arg' redefined
/usr/local/lib/gcc-lib/vax-dec-ultrix4.3/2.4.5/include/varargs.h:97: warning: this is the location of the previous definition
../include/stdarg.h:13: warning: `va_end' redefined
/usr/local/lib/gcc-lib/vax-dec-ultrix4.3/2.4.5/include/varargs.h:88: warning: this is the location of the previous definition
support.c:13: macro `va_start' used with just one arg
support.c:35: macro `va_start' used with just one arg
support.c:50: macro `va_start' used with just one arg
*** Error code 1
com
So there is a discrepency between gcc's va_start and cc's va_start on the
Apollo. Now, here an excerpt from gcc's stdarg.h file :
/* stdarg.h for GNU.
Note that the type used in va_arg is supposed to match the
actual type **after default promotions**.
Thus, va_arg (..., short) is not valid. */
#ifndef _STDARG_H
#ifndef _ANSI_STDARG_H_
#ifndef __need___va_list
#define _STDARG_H
#define _ANSI_STDARG_H_
#endif /* not __need___va_list */
#undef __need___va_list
......some stuff deleted......
#define va_start(AP, LASTARG) \
(AP = ((__gnuc_va_list) __builtin_next_arg ()))
#undef va_end
void va_end (__gnuc_va_list); /* Defined in libgcc.a */
#define va_end(AP)
/* We cast to void * and then to TYPE * because this avoids
a warning about increasing the alignment requirement. */
And here is the usage of va_start in support.c :
mem_printf(va_alist)
va_dcl
{
char *fmt, buf[4096];
va_list args;
fflush(stdout);
va_start(args); /* program crashes here */
fmt = va_arg(args, char *);
vsprintf(buf, fmt, args);
va_end(args); /* and here */
write(1, buf, strlen(buf));
}
What should I do? What , change the arguments to va_start, and if so
to what? Or, can this be handled with an ifdef, if so what would be
the spelling on the command line?
Thanks,
-emmett
Technical Details
Message-ID:
<1993Jul27.202402.5950@nic.csu.net>Path:
arc1-ca.pugleaf.net!gmd.de!Germany.EU.net!mcsun!uunet!olivea!charnel!rat!koko.csustan.edu!nic.csu.net!futon.SFSU.EDU!mcleanShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,d8338d114ab8b161,start X-Google-Attributes: gid11318c,public X-Google-Thread: 1014db,d8338d114ab8b161,start X-Google-Attributes: gid1014db,public X-Google-ArrivalTime: 1993-07-27 23:58:32 PST Path: arc1-ca.pugleaf.net!gmd.de!Germany.EU.net!mcsun!uunet!olivea!charnel!rat!koko.csustan.edu!nic.csu.net!futon.SFSU.EDU!mclean Newsgroups: gnu.gcc.help,comp.lang.c Subject: Seek help with va_start macro in stdarg.h porting from Apollo C Message-ID: <1993Jul27.202402.5950@nic.csu.net> From: mclean@futon.SFSU.EDU (Emmett Mclean) Date: 27 Jul 93 20:24:00 PDT Distribution: world Organization: San Francisco State University Nntp-Posting-Host: futon.sfsu.edu Lines: 75