delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/08/01/13:12:56

X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
Subject: printf
Date: Wed, 1 Aug 2007 13:12:21 -0400
Message-ID: <C6EEDB0EB45A56439F73B1D23E39694A3DED30@USORL02P702.ww007.siemens.net>
From: "Frederich, Eric P21322" <eric DOT frederich AT siemens DOT com>
To: <cygwin AT cygwin DOT com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
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/


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019