Re: Complicated macro...
- From: "James Hess" <mysidia@xxxxxxxxx>
- Date: 9 May 2005 12:37:54 -0700
No Such Luck wrote:
> I had a situation in a C program, which contained hundreds of calls
to
> "fprintf (stdout, ...", where I needed to flush stdout immediately
> after any stream was sent there. More specifically, I needed to add
the
> command "fflush(stdout);" after every command that started with:
>
> fprintf(stdout
Are you familiar with variadic macros?
In C99 you could do something like
#define print_it(file_ptr, format, ...) do \
if (fprintf(file_ptr, format, ##__VA_ARGS__ ) == 0)
fflush(file_ptr);
/* else... handle the error if you like */
while(0)
.
- Follow-Ups:
- Re: Complicated macro...
- From: Michael Mair
- Re: Complicated macro...
- References:
- Complicated macro...
- From: No Such Luck
- Complicated macro...
- Prev by Date: Re: Complicated macro...
- Next by Date: Re: tool to measure performance of written function
- Previous by thread: Re: Complicated macro...
- Next by thread: Re: Complicated macro...
- Index(es):
Relevant Pages
|
Loading