Hi Eric! On Wed, Apr 30, 2014 at 06:51:23PM -0600, Eric Blake 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: Thanks for the idea and the examples! Here's what I came up with: AC_CACHE_CHECK([parameter type for backtrace()], [am_cv_proto_backtrace_type], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[ #include <execinfo.h> extern #ifdef __cplusplus "C" #endif size_t backtrace(void **addrlist, size_t len); ]]) ], [am_cv_proto_backtrace_type=size_t], [am_cv_proto_backtrace_type=int]) ]) AC_DEFINE_UNQUOTED([backtrace_t], [$am_cv_proto_backtrace_type], [Define to return type for backtrace().]) It seems to work fine on NetBSD, OS X, and Linux. This way I can define my variables backtrace_t len; and it'll work even if I don't have any backtrace() functionality. Cheers, Thomas _______________________________________________ Autoconf mailing list Autoconf@xxxxxxx https://lists.gnu.org/mailman/listinfo/autoconf