This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: patch to suggest putc/fputs over printf("string") or printf("\n")
- To: ghazi at caip dot rutgers dot edu (Kaveh R. Ghazi)
- Subject: Re: patch to suggest putc/fputs over printf("string") or printf("\n")
- From: Joe Buck <jbuck at Synopsys dot COM>
- Date: Wed, 13 Jan 99 9:12:24 PST
- Cc: law at cygnus dot com, egcs at cygnus dot com
> I suppose we need to know the stdout expansion for changing
> printf() -> fputs(, stdout) and also for fprintf(stdout, "%s\n",) -> put$
Seems to mee you guys are too smart and are working too hard.
The only reason you need stdout is because there are some functions
that don't take stdout, that have to be turned to a function that does.
The way around that is to introduce new functions that implicitly take
stdout.
e.g.
printf("Hello world\n") -> __fputs_stdout("Hello world\n");
Now, your header file might previously have said
inline int __fputs_stdout(const char* s) { return fputs(s, stdout);}
so you wind up with the same thing. So the only thing that makes stdout
special is its use in these functions, but your translation is portable.