D
David G
void myfunc(char *format, int param1, ...)
{
va_list argp;
va_start(argp, format);
#if CONDITION
some code involving param1
#endif
some code that uses format and argp
va_end(argp);
}
The obvious thing being that the function in question, under certain
build configurations, needs to snoop the first varargs parameter.
I've seen the comment made on various pages about varagrs that the
second parameter to va_start is the last named parameter of the
function, but is this a hard requirement?
The reason I'm curious is that when heavily optimized, when CONDITION
evaluates false, MS VC 2005's compiler will optimize out the
evaluation of param1 since it's not actually used in the function.
This in turn causes all sorts of hell because the parmeters fetched
via argp don't line up properly.
Compiler bug, or are we breaking the law?
{
va_list argp;
va_start(argp, format);
#if CONDITION
some code involving param1
#endif
some code that uses format and argp
va_end(argp);
}
The obvious thing being that the function in question, under certain
build configurations, needs to snoop the first varargs parameter.
I've seen the comment made on various pages about varagrs that the
second parameter to va_start is the last named parameter of the
function, but is this a hard requirement?
The reason I'm curious is that when heavily optimized, when CONDITION
evaluates false, MS VC 2005's compiler will optimize out the
evaluation of param1 since it's not actually used in the function.
This in turn causes all sorts of hell because the parmeters fetched
via argp don't line up properly.
Compiler bug, or are we breaking the law?