diff --git a/configure.ac b/configure.ac index 40f5a583..29890622 100644 --- a/configure.ac +++ b/configure.ac @@ -146,19 +146,14 @@ if test "$os_unix" = "yes"; then AC_CHECK_FUNC( [strerror_r], - [AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ - #include - #include - - int main (void) - { - char buf[32]; - return strerror_r (EINVAL, buf, 32); - } - ]])], - [AC_DEFINE([HAVE_XSI_STRERROR_R], 1, [Whether XSI-compliant strerror_r() is available])], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include + #include ]], + [[/* GNU strerror_r returns char *, XSI returns int */ + char buf[32]; + return *strerror_r (EINVAL, buf, 32);]])], [AC_DEFINE([HAVE_GNU_STRERROR_R], 1, [Whether GNU-specific strerror_r() is available])], + [AC_DEFINE([HAVE_XSI_STRERROR_R], 1, [Whether XSI-compliant strerror_r() is available])], [])], []) diff --git a/meson.build b/meson.build index 0f8c8da0..9a72e148 100644 --- a/meson.build +++ b/meson.build @@ -301,20 +301,21 @@ endforeach if cc.has_function('strerror_r', prefix: '#include ') strerror_r_code = ''' +#define _GNU_SOURCE #include #include int main (void) { + /* GNU strerror_r returns char *, XSI returns int */ char buf[32]; - return strerror_r (EINVAL, buf, 32); + return *strerror_r (EINVAL, buf, 32); } ''' - strerror_r_check = cc.run(strerror_r_code, name : 'strerror_r check') - if strerror_r_check.returncode() == 0 - conf.set('HAVE_XSI_STRERROR_R', 1) - else + if cc.compiles(strerror_r_code, name : 'GNU strerror_r check') conf.set('HAVE_GNU_STRERROR_R', 1) + else + conf.set('HAVE_XSI_STRERROR_R', 1) endif endif