This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: printf

"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:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]