autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature suggestion: how to figure out specific size types.


From: Keith Bostic
Subject: feature suggestion: how to figure out specific size types.
Date: Tue, 22 May 2001 11:00:31 -0400 (EDT)

A feature I would like to see in autoconf is a way to find out
how to typedef to a specific size on a system.

For example, databases need to write fixed-size information into
memory and onto disk, and so have to know how big a type really is.

Another example are applications that are written (correctly)
to use ssize_t.  If the system has a size_t, but not a ssize_t,
to what type do you typedef the ssize_t?  It's a "signed size_t",
but it's hard to figure out how big a size_t is so you can get
that right.

I currently do something like the following for all the types
I care about:

        AC_SUBST(u_int16_decl)
        AC_CACHE_CHECK([for u_int16_t], db_cv_uint16, [
        AC_TRY_COMPILE([#include <sys/types.h>], u_int16_t foo;,
                [db_cv_uint16=yes],
        AC_TRY_RUN([main(){exit(sizeof(unsigned short) != 2);}],
                [db_cv_uint16="unsigned short"],
        AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 2);}],
                [db_cv_uint16="unsigned int"], [db_cv_uint16=no])))])
        if test "$db_cv_uint16" = no; then
                AC_MSG_ERROR([No unsigned 16-bit integral type.])
        fi
        if test "$db_cv_uint16" != yes; then
                u_int16_decl="typedef $db_cv_uint16 u_int16_t;"
        fi

If it would be of interest to the maintainers, and you folks would
tell me what you'd like the interfaces to be, I'd be happy to write
some macros to do the work and contribute them back.

Regards,
--keith

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Keith Bostic
Sleepycat Software Inc.         address@hidden
118 Tower Rd.                   +1-781-259-3139
Lincoln, MA 01773               http://www.sleepycat.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]