compile using gcc with varargs.h

My problem:

        I cannot compile program with "#include <varargs.h>".

        The error was ... __builtin_va_arg_incr is undefined.

The solutions I received are:

        1) __builtin_va_arg_incr is special name for Sun

           compiler which gcc doesn't recognize.

        2) gcc has its own set of include files including

           the new varargs.h.

        3) On my machine, the new varargs.h is in

           LIBDIR/include/tmpdir/varargs.h so I move it out

           to LIBDIR/include/varargs.h so that gcc will find

           it... and everything is ok.

Special thanks to:

        Kayvan Sylvan <kayvan@satyr.Sylvan.COM>

        Sven Heinicke <sven@wells.nrl.navy.mil>

        Joe McGuckin <oilean!joe@sgi.com>

--------------------------------------------------------------------

>Fromkayvan@satyr.Sylvan.COM Sun Jan 30 01:10:19 1994

Date: Mon, 24 Jan 94 19:11 PST

From: Kayvan Sylvan <kayvan@satyr.Sylvan.COM>

To: "Mr. Santithorn Bunchua" <keh@abac.au.ac.th>

Subject: Compiling program with <varargs>

There's a typo in Sun's header file.

I don't have the source in front of me right now, but I remember

reporting this and fixing it while I was working as a consultant at

Sun.

What I remember is that there were two sections that define the

varargs based on the compiler and use a couple of variables. The

variables are named incorrectly in the section that gcc sees.

                        ---Kayvan

| Kayvan Sylvan, Sylvan Associates,kayvan@satyr.Sylvan.COM, (408) 978-1407 |

| Consulting, Training, Development, SysAdmin, {BSD,SVr3,SVr4} Unix Systems |

| "Think Globally, Act Locally." "Only you can make your dreams come true." |

| Proud Dad of Katherine Yelena (born 8/8/89) & Robin Gregory (born 2/28/92) |

------------------------------------------------------------------------------

>Fromsven@wells.nrl.navy.mil Sun Jan 30 01:10:09 1994

Date: Tue, 25 Jan 94 09:23:12 -0500

From: Sven Heinicke <sven@wells.nrl.navy.mil>

To: "Mr. Santithorn Bunchua" <keh@abac.au.ac.th>

Subject: Re: Compiling program with <varargs>

I hacked around with your code and it worked no problem (my final code

is appended at the end of this message). What version of gcc are you

using? Here is what I'm using:

% gcc -v

Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.2/2.5.2/specs

gcc version 2.5.2

Perhaps your version of gcc is installed wrong. check out which

varargs.h file you are loading. Make the first line of your c program

'#include <varargs.h>' and then do this (Assuming your C program is

called t.c):

gcc -E t.c > t.i

One of the first lines of t.c should look something like:

# 1 "/usr/local/lib/gcc-lib/sparc-sun-solaris2.2/2.5.2/include/varargs.h" 1 3

how does it look?

oh, I just thought of something else. are you using the ftp'd

solaris2 binaries or the binaries off the demo CD? If so the first

thing you should do is down load the latest version and rebuild it.

People have gotten a lot of strange problems downloading binaries. I

downloaded the binaries and the first thing I did was download the

latest GCC sources and rebuild it. If this is the problem recontact

me too as there are a few instructions you should know about building

the GNU gcc with the solaris2 binaries.

                Sven

#include <varargs.h>

main

()

{

  test (1, 2, 3, 0);

}

void test (va_alist)

va_dcl

{

  va_list ap;

  int p;

  

  va_start (ap);

  while ( (p = va_arg (ap, int)) != 0)

    {

      printf ("%d", p);

    }

  va_end (ap);

}

---------------------------------------------------------------------

>From oilean!joe@sgi.com Sun Jan 30 01:10:03 1994

Date: Mon, 24 Jan 94 22:32:33 PST

From: Joe McGuckin <oilean!joe@sgi.com>

To:keh@abac.au.ac.th

Subject: Re: Compiling program with <varargs>

The __builtin_va_arg_incr symbol is a magic cookie that the Sun compilers recognize -

this tells them to generate code for varargs parameter passing. The Gnu compilers

probably don't treat the __builtin_va_arg_incr symbol as 'special' - they treat it as a

normal symbol.

I suggest that you use the Gnu headers if they are available.

-----------------------------------------------------------------------

The END of SUMMARY.

--keh--

[7813 byte] By [CodeProf.com] at [2007-12-25 8:40:00]