ftp.nice.ch/peanuts/GeneralData/Usenet/news/1989/CSN-89.tar.gz#/comp-sys-next/1989/Sep/Variable-Length-Argument-Lists-for-Methods

This is Variable-Length-Argument-Lists-for-Methods in view mode; [Up]


Date: Sun 13-Sep-1989 02:52:45 From: Unknown Subject: Variable Length Argument Lists for Methods 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. >From: hughes@silver.bacs.indiana.edu (larry hughes)

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Marcel Waldvogel and Netfuture.ch.