[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re[2]: c macro
Liron Levy <liron@pointer.co.il> wrote:
> > > I'm tring to make any on that uses printf to
> > > use sprintf instead
> > >
> > > somthing like:
> > >
> > > #ifdef LINUX
> > > #define printf(...) {sprintf(s,...);do_print(s);}
> > > #endif
> >
> > static char s[256];
> > #define printf(args... ) sprintf(s, ## args); do_print(s)
> >
> > Notice that it's a GCC extension; in the ANSI C there is no way of doing
> such a
> > thing.
> >
>
> There is a way to do this with the ANSI C preprocessor assuming that you are
> willing to live with
> a small restriction, namely - putting the list of varargs in parens. The
> pre-processor will chew that
> easily.
Apparently, you didn't read the original post carefully. "putting the list of
varargs in parens" means changing every instance of printf() in an existing
source file - that's what Erez tried to avoid.
Regards,
Evgeny
--
____________________________________________________________
/ Evgeny Stambulchik <fnevgeny@plasma-gate.weizmann.ac.il> \
/ Plasma Laboratory, Weizmann Institute of Science, Israel \ \
| Phone : (972)8-934-3610 == | == FAX : (972)8-934-3491 | |
| URL : http://plasma-gate.weizmann.ac.il/~fnevgeny/ | |
| Finger for PGP key >=====================================+ |
|______________________________________________________________|