-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 At some point hitherto, Jerry Feldman hath spake thusly: > In short, macros do not support variable arguments, but.... Well, at least with Gnu tools, yes they do. See my previous post. I haven't tried this with any proprietary compiler, as I currently don't have access to any. > You are better off using a C function for that (assume you include > stdarg.h). > int printerr(const star *fmt, ...) > { > va_list ap; > int rv; > time_t now = time(NULL); > char msg[SOMESIZE]; > va_start(ap, fmt); > sprintf(msg, "%s - ERROR: %s", ctime(&now), fmt); > rv = vfprintf(logfile, msg, ap); > return rv; > } This reminds me; your implementation (if you're not using glibc) may not have vsnprintf(). If you're writing to a file, you can use a method something like gaf's above. Most implementations have vfprintf() which make that possible. If you're using some other API, such as to log a message to syslog, that won't work (because you need to have the message you're logging in a buffer to pass to syslog()). In such a case, you can borrow the source for vsnprintf() from the glibc source. Many Gnu programs explicitly include the source for functions added by the most recent C standards (such as vsnprintf()), as many older implementations don't have them. Chances are fair that if you've got the source for any Gnu program laying around, the code for vsnprintf() might be with it. - -- Derek Martin ddm@pizzashack.org - --------------------------------------------- I prefer mail encrypted with PGP/GPG! GnuPG Key ID: 0x81CFE75D Retrieve my public key at http://pgp.mit.edu Learn more about it at http://www.gnupg.org -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE9DPtedjdlQoHP510RAoCDAJ9229nJvYv+0++OEzk9iYcuuT9AiwCgj29r BOyJKvoFQHg74CzRL9giFKQ= =02N5 -----END PGP SIGNATURE-----