This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: "stdarg.h", va_start(), with gcc.
- From: Jeffrey_Yuan at exe dot com
- To: gcc-help at gcc dot gnu dot org
- Date: Sat, 8 Jan 2005 18:25:32 -0600
- Subject: Re: "stdarg.h", va_start(), with gcc.
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@ssaglobal.com
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