Re: Variable argument list not working
Re: Variable argument list not working
- Subject: Re: Variable argument list not working
- From: Pierre-Olivier Latour <email@hidden>
- Date: Tue, 13 Aug 2002 20:23:53 +0200
>
On Tuesday, August 13, 2002, at 01:56 PM, Pierre-Olivier Latour wrote:
>
>
> In a .cp file I have this function I'd like to call (it's just a test
>
> now:
>
> it'll get more complicated later ;) ):
>
>
>
> void PixelShox_LogMessage(PSEStringPtr message, ...)
>
> {
>
> va_list args;
>
>
>
> va_start(args, message);
>
> printf(message, args);
>
>
This is incorrect.
>
>
> va_end(args);
>
> printf("\n");
>
> }
>
>
You need to use vprintf here, not printf.
OK, that sample works now, thanks. Unfortunately, it's still not working for
my more complex goal:
typedef void (*PixelShoxProc_LogOutput)(char* message, ...);
static PixelShoxProc_LogOutput logOutput;
void PixelShox_LogMessage(char* message, ...)
{
if(logOutput) {
va_list args;
va_start(args, message);
(*logOutput)(message, args);
va_end(args);
}
}
LogOutput is set to:
static void LogMessage(char* message, ...)
{
va_list args;
va_start(args, message);
vprintf(message, args);
va_end(args);
printf("\r");
}
The problem is I need to pass a variable argument list, not a "va_list"
argument? Is this possible?
****
Does all this works only with GCC or with any C compiler? I need to write
standard portable code.
_____________________________________________________________
Pierre-Olivier Latour email@hidden
Lausanne, Switzerland
http://www.pol-online.net
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.