• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Variable argument list not working
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Variable argument list not working
      • From: Ondra Cada <email@hidden>
    • Re: Variable argument list not working
      • From: Jim Correia <email@hidden>
References: 
 >Re: Variable argument list not working (From: Jim Correia <email@hidden>)

  • Prev by Date: Re: [TRTFM] Cocoa and AppleScript
  • Next by Date: Re: Variable argument list not working
  • Previous by thread: Re: Variable argument list not working
  • Next by thread: Re: Variable argument list not working
  • Index(es):
    • Date
    • Thread