Path: utzoo!attcan!uunet!pyrdc!lighthouse!brian
From: brian@lighthouse.com (Brian Douglas Skinner)
Newsgroups: comp.sys.next
Subject: Re: Variable Length Argument Lists for Methods--REPOST
Message-ID: <1989Sep23.215508.5568@lighthouse.com>
Date: 23 Sep 89 21:55:08 GMT
Organization: Lighthouse Design, Ltd.
Lines: 62



In article <1989Sep13.025245.1193@lighthouse.com>, I wrote what
follows.  However, no one seems to have responded.  We're still
looking for answers...

>We're trying to write a method that takes a variable number of
>arguments, something like:
>
>[error notify: "Error at line %i in file %s", __LINE__, __FILE__];
>
>or 
>
>[error notify: "Error: %s at line %i in file %s", "Big Bummer",
>__LINE__, __FILE__];
>
>We've settled on
>
>- error: (char *)format, ...;
>
>in our .h file (based on selectorRPC:paramTypes:... in Speaker.h), but
>we haven't stumbled onto how to write the method.
>
>On page 4-13 of the Objective-C Compiler User Reference Manual (in
>Volume 3 of the NeXT 0.9 Technical Documentation) is written
>
>- error:( char * ) format ; int aList ;
>//                        ^
>//                        might be a colon; can't tell
>
>However, this results in a compiler error.
>
>We've tried variations on the ANSI stdarg technique, and we've tried
>messing directly with pointers, to no avail.
>
>In our .m file, we can use
>
>- error: (char *)format, ...
>{
>    char *args;
>    char **scary;
>    char out[255];
>
>    scary = &format;
>    scary++;
>    args = *scary;
>
>    sprintf(out, format, args);
>    NXAlert(out, "OK", NULL, NULL);
>
>    return self;
>}
>
>without getting a compiler error, but it dumps core in sprintf.
>
>Hints and code fragments would be greatly appreciated.

Thanks,
Brian Skinner
Lighthouse Design, Ltd.
Usenet:   ...!uunet!lighthouse!brian
Internet: brian@lighthouse.com