Re: "stdarg.h", va_start(), with gcc.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 







Hi,

I am trying to create a program on Solaris with GCC.  I has to use
va_start().  The way I use "va_start" in my program as follows:

#include <stdarg.h>

trace(char *fmt, ...)
{
        va_list ap;
        if (tracing)
        {
                va_start(ap, fmt);
                fprintf(stderr, "TRACE: [%s] ", get_timestamp());
                vfprintf(stderr, va_arg(ap, char*), ap);
                fprintf(stderr, "\n");
                va_end(ap);
        }
}

In calling function,
....

trace("Creating socket on port %i", config_getPort());
....

I got an error "Segmentation Fault(coredump)" on that call to function
"trace".  But the program works if I compile it on Aix with cc compiler
(not gcc).

Can anyone advise what was wrong in my code?  Please show me the correct
way to use "va_start".

Many thanks in advance!


Jeffrey Yuan
SSA Global
214-775-5946
jeffrey.yuan@xxxxxxxxxxxxx

Learn why 13,000 businesses worldwide rely on SSA Global to extend ERP
across all their enterprise processes -- from supplier to employee to
customer.
Get started by visiting www.ssaglobal.com


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux