Home
| Calendar
| Mail Lists
| List Archives
| Desktop SIG
| Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU |
In short, macros do not support variable arguments, but.... 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; } Instead of ctime, I would probably use strftime and format the date differently, but ctime works fine). Frank Ramsay wrote: > I'm horrible with Macros in C does anyone know how to make a macro that w > > Now I have a ton of these so altering them manually would take much longer > than I have. Does anyone know of a macro or function that takes var args for > > printf and re-formats them to a more logfile friendly format? > > ie > printerror("file %d not found.\n",filename); > > but what I want is something like this is this > > Sat Jun 15 11:44:02 - ERROR: file greeting.vox not found. > > > -fjr > > > _______________________________________________ > Discuss mailing list > Discuss at blu.org > http://www.blu.org/mailman/listinfo/discuss > -- Jerry Feldman <gaf at blu.org> Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
BLU is a member of BostonUserGroups | |
We also thank MIT for the use of their facilities. |