Mail Archives: djgpp/2003/08/04/12:30:09
Quasar <haleyjd AT hotmail DOT com> wrote:
[...]
> question here is a "portable" snprintf implementation which I have added
> recently because some of my target platforms totally lack or have
> questionable implementations of snprintf and vsnprintf. It uses the
> fcvt function in one place in its double formatting code.
A truly portable snprintf() implementation is impossible, at close to
100% certainly level. The need to use utterly unportable functions
like fcvt() is just one symptom of that fact. In other words: you're
driving out Baal by invoking Beelzebub.
If you need snprintf(), but there is none in the platform's libc that
you can use, you're toast. Period. This is of course the actual
reason why snprintf() was added to C99 in the first place.
Only a compiler implementor (in this case: the DJGPP team) can write a
complete and efficient implementation of snprintf(). User code
generally can't. Floating point stuff is the main obstacle here, but
integers can be surprisingly hairy to get right, too.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -