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

X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
Subject: RE: printf
Date: Wed, 1 Aug 2007 16:55:47 -0400
Message-ID: <C6EEDB0EB45A56439F73B1D23E39694A3DEDBC@USORL02P702.ww007.siemens.net>
In-Reply-To: <46B0C457.4A512ECF@dessent.net>
References: <C6EEDB0EB45A56439F73B1D23E39694A3DED30 AT USORL02P702 DOT ww007 DOT siemens DOT net> <46B0C457 DOT 4A512ECF AT dessent DOT 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-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT 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 l71KuCJD031765

"Brian Dessent" Wrote:

> 1. gcc does not implement a C library, so there is no 
> implementation of any printf in gcc.  The C library
> is separate from gcc, gcc is just the  compiler.
> 2. libiberty is only a portabilty library.  It does
> not implement any actual printf code (it just calls
> the C library's fprintf as you discovered.)
> 3. glibc is only used on linux.  On Cygwin and MinGW
> you are not using glibc.

Do vfprintf statements compiled on Cygwin go through libiberty which
then calls fprintf, or is there another vfprintf in whatever C library
I'm linking against (either Cygwin's or Microsoft's)?

> I'd say it would be pretty silly do reimplement all of the 
> actual printf guts just to do file multiplexing, but
> whatever.  If you want to see the underlying
> implementation of printf that Cygwin uses, look in newlib. 
> If you want to see the underlying implementation of printf
> that MinGW uses, you need the source code to MSVCRT which
> I believe is only available if you buy MS Visual Studio.

What I'm planning on doing is having a library with a printf-like
function where I can do...

float radius = 1.0;
mySpecialPrintf(f1,f2,"The radius is %f %U\n",radius,"in","mm");

And the result would be that in one file you get
"The radius is 1.000 in"
And in the other you'd get...
"The radius is 25.40 mm"

Basically it would be just like printf except that it is printing to two
files and that any floating point printing gets converted.
So what I'd have to change is that %f eats 3 arguments, the number and
two units.  Then I'd call a unit conversion library.
I'd also create a new format (not sure if capital U is taken already) to
print the previously used units.

Having this library would avoid me writing two fprintf statements and
having to do all the converstion inside the main program.

--
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