Mail Archives: djgpp/2003/08/05/16:15:29
On 4 Aug 2003 15:31:31 GMT, Hans-Bernhard Broeker wrote:
> 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.
Aside from the use of fcvt in one place, the rest of the code is pure
ANSI C. It's probably not as efficient as some libc implementations, but
it may be more efficient than some others, according to what I read on
the guy's site where I picked it up. Also, it's not just the presence of
the function that concerns me, but its behavior. Some compilers have
s(n)printf's that are buggy or not really standard compliant. Using one
implementation on all the platforms I target guarantees the same
behavior everywhere. I consider that a very valuable feature.
James
- Raw text -