This macro checks for the size of TYPE using compile checks, not
run checks. You can supply extra HEADERS to look into. the check
will cycle through 1 2 4 8 16 and any EXTRA_SIZES the user
supplies. If a match is found, it will #define SIZEOF_`TYPE' to
that value. Otherwise it will emit a configure time error
indicating the size of the type could not be determined.
The trick is that C will not allow duplicate case labels. While
this is valid C code:
switch (0) case 0: case 1:;
The following is not:
switch (0) case 0: case 0:;
Thus, the AC_TRY_COMPILE will fail if the currently tried size
does not match.
Here is an example skeleton configure.in script, demonstrating the
macro's usage:
AC_PROG_CC
AC_CHECK_HEADERS(stddef.h unistd.h)
AC_TYPE_SIZE_T
AC_CHECK_TYPE(ssize_t, int)
headers='#ifdef HAVE_STDDEF_H
#include <stddef.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
'
AC_COMPILE_CHECK_SIZEOF(char)
AC_COMPILE_CHECK_SIZEOF(short)
AC_COMPILE_CHECK_SIZEOF(int)
AC_COMPILE_CHECK_SIZEOF(long)
AC_COMPILE_CHECK_SIZEOF(unsigned char *)
AC_COMPILE_CHECK_SIZEOF(void *)
AC_COMPILE_CHECK_SIZEOF(size_t, $headers)
AC_COMPILE_CHECK_SIZEOF(ssize_t, $headers)
AC_COMPILE_CHECK_SIZEOF(ptrdiff_t, $headers)
AC_COMPILE_CHECK_SIZEOF(off_t, $headers)