From: mquinson Date: Tue, 1 Mar 2005 07:43:43 +0000 (+0000) Subject: Check whether printf(%s,NULL) works or segfaults X-Git-Tag: v3.3~4228 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/0458bcfaa9cb1c7c87e15f4ec14fa7de1a130a1f Check whether printf(%s,NULL) works or segfaults git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1125 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/acmacro/print_null.m4 b/acmacro/print_null.m4 new file mode 100644 index 0000000000..ee5787cc24 --- /dev/null +++ b/acmacro/print_null.m4 @@ -0,0 +1,23 @@ +dnl AC_CHECK_PRINTF_NULL: Check whether printf("%s",NULL) works or segfault + +dnl it uses AC_RUN and assume the worse while cross-compiling + +dnl Then, you can: +dnl #ifndef PRINTF_NULL_WORKING +dnl # define PRINTF_STR(a) (a)?:"(null)" +dnl #else +dnl # define PRINTF_STR(a) (a) +dnl #endif + +AC_DEFUN([AC_CHECK_PRINTF_NULL], + [ +AC_MSG_CHECKING([whether printf("%s",NULL) works...]) +AC_RUN_IFELSE(AC_LANG_PROGRAM([#include ], + [printf("%s",NULL);]), + AC_DEFINE(PRINTF_NULL_WORKING, + 1, + [Indicates whether printf("%s",NULL) works]) + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no), + AC_MSG_RESULT(assuming the worse in cross-compilation)) +])