X-Spam-Check-By: sourceware.org
Content-class: urn:content-classes:message
MIME-Version: 1.0
Content-Type: text/plain; 	charset="us-ascii"
Subject: printf
Date: Wed, 1 Aug 2007 13:12:21 -0400
Message-ID: <C6EEDB0EB45A56439F73B1D23E39694A3DED30@USORL02P702.ww007.siemens.net>
From: "Frederich, Eric P21322" <eric.frederich@siemens.com>
To: <cygwin@cygwin.com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id l71HCiOg030050

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/


