Awh cool thanks for sharing that i couldn't figure out how to do this with something in work. On 1 May 2014 01:51, Eric Blake <eblake@xxxxxxxxxx> wrote: > On 04/30/2014 06:12 PM, Thomas Klausner wrote: >> Hi! >> >> I found out that the prototypes for backtrace() and backtrace_symbol() >> differ on some operating systems. >> > >> >> The main difference is that on NetBSD, size_t is used for most >> arguments that are int on the other systems; also, >> backtrace_symbols_fd returns an int. >> >> I'd like to test for the difference int <-> size_t in a configure >> script so I can get integer type/sign conversion-warnings free code on >> all these operating systems. >> >> I'm however not sure how to do this. Does anyone have a suggestion? > > Yep - use function pointer assignment or redeclaration to force the > compiler to complain if the redeclaration used the wrong type. Gnulib > has some examples; here's one with ioctl(), which on Linux takes an > 'unsigned long' instead of the POSIX 'int' for the second parameter: > > AC_CACHE_CHECK([for ioctl with POSIX signature], > [gl_cv_func_ioctl_posix_signature], > [AC_COMPILE_IFELSE( > [AC_LANG_PROGRAM( > [[#include <sys/ioctl.h>]], > [[extern > #ifdef __cplusplus > "C" > #endif > int ioctl (int, int, ...); > ]]) > ], > [gl_cv_func_ioctl_posix_signature=yes], > [gl_cv_func_ioctl_posix_signature=no]) > ]) > if test $gl_cv_func_ioctl_posix_signature != yes; then > REPLACE_IOCTL=1 > fi > > Or this one originally from gettext (but annoyingly encroaching on > automake's namespace), checking whether iconv() uses a const or not: > > AC_MSG_CHECKING([for iconv declaration]) > AC_CACHE_VAL([am_cv_proto_iconv], [ > AC_COMPILE_IFELSE( > [AC_LANG_PROGRAM( > [[ > #include <stdlib.h> > #include <iconv.h> > extern > #ifdef __cplusplus > "C" > #endif > #if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) > size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * > *outbuf, size_t *outbytesleft); > #else > size_t iconv(); > #endif > ]], > [[]])], > [am_cv_proto_iconv_arg1=""], > [am_cv_proto_iconv_arg1="const"]) > am_cv_proto_iconv="extern size_t iconv (iconv_t cd, > $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * > *outbuf, size_t *outbytesleft);"]) > am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e > 's/( /(/'` > AC_MSG_RESULT([ > $am_cv_proto_iconv]) > AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1], > [Define as const if the declaration of iconv() needs const.]) > > Hopefully that gives you some ideas. > > -- > Eric Blake eblake redhat com +1-919-301-3266 > Libvirt virtualization library http://libvirt.org > > > _______________________________________________ > Autoconf mailing list > Autoconf@xxxxxxx > https://lists.gnu.org/mailman/listinfo/autoconf > _______________________________________________ Autoconf mailing list Autoconf@xxxxxxx https://lists.gnu.org/mailman/listinfo/autoconf