[Zlib-devel] Re: snprintf

Nelson H. F. Beebe beebe at math.utah.edu
Thu Mar 13 06:54:01 EST 2003


Mark Adler <mark.adler at quest.jpl.nasa.gov> writes on Wed, 12 Mar 2003 23:36:24 -0800:

>> It would be nice if someone with a compiler that in fact doesn't have snprint() 
>> or vsnprintf() could verify that.

I resurveyed about 15 flavors of Unix a couple of days ago in
connection with installation of another package that needed
snprintf().  The only one that lacks it is Compaq/DEC Alpha OSF/1 4.0,
so I'll be able to check whether zlib is handling this properly.
OSF/1 5.1 DOES have the function.

One possible solution is to provide a private fallback version of
snprintf.  I did a Web search, found many, and selected this one:

	http://www.ijs.si/software/snprintf/

Take at look at the section ``Portability of C Functions'' in the GNU
autoconf manual: it discusses sprintf() and snprintf() issues.  The
AC_LIBOBJ() function provides an easy way to test for a
sometimes-missing function, and set the Makefile to use a private
version.

[Mark, please send me off-list a pointer to a zlib distribution that
has the relevant code, and I'll check the build on our Alpha system.]

The good news for snprintf() fans is that the 1999 ISO C Standard
includes snprintf() and vsnprintf().  History suggests that it will
take at least another couple of years before all vendors reach that
level of conformance.  So far, I have only one C compiler (out of 40+)
that fully supports C99, and one C++ compiler (out of 30+) that
supports C++98.


-------------------------------------------------------------------------------
- Nelson H. F. Beebe                    Tel: +1 801 581 5254                  -
- Center for Scientific Computing       FAX: +1 801 581 4148                  -
- University of Utah                    Internet e-mail: beebe at math.utah.edu  -
- Department of Mathematics, 110 LCB        beebe at acm.org  beebe at computer.org -
- 155 S 1400 E RM 233                       beebe at ieee.org                    -
- Salt Lake City, UT 84112-0090, USA    URL: http://www.math.utah.edu/~beebe  -
-------------------------------------------------------------------------------




More information about the Zlib-devel mailing list