This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
Re: fprintf control from Environment variable.
- From: Ian Lance Taylor <iant at google dot com>
- To: naveen yadav <yad dot naveen at gmail dot com>
- Cc: glibc-bugs at sourceware dot org, gcc-help at gcc dot gnu dot org
- Date: Tue, 9 Oct 2012 06:39:37 -0700
- Subject: Re: fprintf control from Environment variable.
- References: <CAJ8eaTxfW_sJ9=ZYKvYwwnrgckxtmNopQ3NYG215+fZ1rBvktA@mail.gmail.com>
On Mon, Oct 8, 2012 at 10:22 PM, naveen yadav <yad.naveen@gmail.com> wrote:
>
> I want to control the print message being sent to stdout and stderr
> using printf(), vprintf() and fprintf() function call for better
> performance.
>
> For this I have added following code in vfprintf() function
> static int Verbose = 0;
> if(stream == stdout || stream == stderr)
> {
> if (Verbose == 0)
> Verbose = getenv ("PRINT") ? 1 : 2;
> if (Verbose == 1)
> return 0;
> }
That seems really unwise. Do this kind of thing in your application,
not in your C library. If for some reason you truly must do it in
your C library, do it at level of write, not at the level of printf.
Ian