Mail Archives: cygwin/2007/08/01/13:12:56
Hello guys,
I came across this page comparing different implementations of printf.
http://www.and.org/vstr/printf_comparison
The author says...
"Note that if you want a portable version of printf() in your code, you
are _much_ better off using something that natively parses the format
string. This ensures that you get the same parsing behavior on all
platforms"
If in cygwin, I have a c file like so...
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[]){
printf("Which printf am I using?\n");
}
... and I compile it under cygwin with "gcc -mno-cygwin test.c"...
Would I be using one that "natively parses the format string"?
... now if I compile without the -mno-cygwin option, what happens?
I was looking around in some gcc source code for printf and found
vprintf.c which calls vfprintf.c with stdout, which calls _doprnt.
All of these were in a directory called "libiberty". Furthermore, the
_doprnt winds up calling fprintf.
Does GCC have it's own implementation of printf and is it different than
glibc's implementation?
As you can tell, I don't understand much about this. Why would both gcc
and glibc have a printf implementation? Any help is appreciated.
I am also looking into this because I wanted to create my own
specialized version of printf which prints to two files with just one
function call. I would be doing some different things on each file. I
was looking for a good vfprintf to start with.
Thanks,
~Eric
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -