Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Check whether printf(%s,NULL) works or segfaults
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 1 Mar 2005 07:43:43 +0000 (07:43 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 1 Mar 2005 07:43:43 +0000 (07:43 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1125 48e7efb5-ca39-0410-a469-dd3cf9ba447f

acmacro/print_null.m4 [new file with mode: 0644]

diff --git a/acmacro/print_null.m4 b/acmacro/print_null.m4
new file mode 100644 (file)
index 0000000..ee5787c
--- /dev/null
@@ -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 <stdio.h>],
+                              [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))
+])