*BSD News Article 78187


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.mel.connect.com.au!news.syd.connect.com.au!phaedrus.kralizec.net.au!not-for-mail
From: bde@zeta.org.au (Bruce Evans)
Newsgroups: comp.unix.bsd.freebsd.misc,gnu.g++.help
Subject: Re: g++2.7.2 error on freebsd
Date: 13 Sep 1996 06:52:14 +1000
Organization: Kralizec Dialup Unix
Lines: 63
Message-ID: <519t5u$hk8@godzilla.zeta.org.au>
References: <8414360547401@maverick.mcs.anl.gov> <50ee1f$dp@anorak.coverform.lan> <50t8s1$lhr@news1.infinet.com> <84219523715529@maverick.mcs.anl.gov>
NNTP-Posting-Host: godzilla.zeta.org.au
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:27180 gnu.g++.help:13305

In article <84219523715529@maverick.mcs.anl.gov>,
Satish Balay <balay@maverick.mcs.anl.gov> wrote:

>...
>c , c++ compilers.). But on freebsd using g++2.7.2, we get this strange
>warinig message, which dos'nt occur on ANY OTHER PRATFORM (other compilers,
>older versions of g++, g++2.7.2 on sun4, LINUX, DEC alpha). This
>kinad of sugests that either g++-2.7.2 on freebsd is screwed up,
>or they implemented a new feature of C++ not implemneted on g++2.7.2
>on other arch. In either case, how do i get rid of this warning message?
>...

gcc-2.7.2 isn't really supported on FreeBSD yet.  The gcc-2.7.2
distribution misconfigures some things.

>----------
>#include <stdio.h>
>#include <stdarg.h>
>
>
>int NewPrintf(char *format,...)
>{
>  int rank;
>  va_list Argp;
>
>  va_start( Argp, format );
>  vfprintf(stdout,format,Argp); 
>  va_end( Argp );
>  fflush(stdout);
>  return 0;
>}
>
>
>int main ()
>{
>  int a=10, b=20,c=30;
>  NewPrintf( "A = %d B = %d C = %d\n",a,b,c);
>  return 0;
>} 
>------------------
>elvis:/home/balay/junk>!g++
>g++ printf.c
>printf.c: In function `int NewPrintf(char * ...)':
>printf.c:11: warning: ANSI C++ forbids implicit conversion from `void *' in argument passing
>elvis:/home/balay/junk>a.out
>A = 10 B = 20 C = 30
>-------------------

This occurs because va_list is of type `void *', but vfprintf()'s third
arg is of type `_BSD_VA_LIST_' = `char *'.  _BSD_VA_LIST_ is a macro
that is supposed to give the same type as va_list.  gcc's stdarg.h
attempts to support this macro but gets it completely wrong.  First,
it is misspelled as _BSD_VA_LIST, so the system macro is unaffected.
Second, it is impossible to change the system type to match gcc's type
by supplying a modified <stdarg.h> - either <machine/stdarg.h> must
be modified, or gcc's type must be changed to match the system type.
Third, it #undef's _BSD_VA_LIST, but #undef'ing it would break <stdio.h>
if it were spelled correctly.  (It is used in <stdio.h> to avoid the
namespace pollution that would occur if <stdarg.h> were included.)

There are many other similarly trivial configuration problems.
-- 
Bruce Evans  bde@zeta.org.au