Re: how could I write this cpp macro
- From: "David Resnick" <lndresnick@xxxxxxxxx>
- Date: 31 Aug 2006 10:58:20 -0700
Ben Pfaff wrote:
Bilgehan.Balban@xxxxxxxxx writes:
I'm trying to convert this:
printf("format str %s, %s", "str arg 1", "str arg 2 etc.");
to this:
printf("%s: " "format str %s, %s", __FUNCTION__, "str arg 1", "str arg2
etc.");
It's ghastly, but
#define pdebug printf("%s:", __FUNCTION__), printf
might do what you want.
There are probably C99-specific solutions, and definitely
GCC-specific solutions, as well.
I think Ben's solution or a variant of it may be what you want. Your
method of concatenating string literals precludes people from using a
variable as the format string, not ideal if this is to be widely used.
e.g.
const char *format = "%s %d %s";
pdebug(format, foo, bar, bas);
would break.
-David
.
- References:
- how could I write this cpp macro
- From: Bilgehan . Balban
- Re: how could I write this cpp macro
- From: Ben Pfaff
- how could I write this cpp macro
- Prev by Date: Re: how could I write this cpp macro
- Next by Date: Re: [Newbie] changing allocated memory
- Previous by thread: Re: how could I write this cpp macro
- Next by thread: Re: how could I write this cpp macro
- Index(es):