r13071: Work around a really annoying compiler warning where header file
authorJames Peach <jpeach@samba.org>
Sun, 22 Jan 2006 23:48:56 +0000 (23:48 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:51:21 +0000 (13:51 -0500)
ordering causes MIN and MAX to be redefined.

source/build/m4/rewrite.m4
source/include/system/filesys.h

index 92bcdc04143fc5127db53db8e1d0422b4450c2a1..0bdd181a55f69015218fe8d7bb7cabb8fd51ba7b 100644 (file)
@@ -67,6 +67,27 @@ AC_CHECK_HEADERS(sys/mount.h, , , [AC_INCLUDES_DEFAULT
 #include <sys/param.h>
 #endif])
 
+AC_CACHE_CHECK([for MAX in sys/param.h], samba_cv_sys_param_h_max,
+       AC_TRY_COMPILE([
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif], [int i = MAX(1,2)],
+       samba_cv_sys_param_h_max=yes, samba_cv_sys_param_h_max=no) )
+
+if test x"$samba_cv_sys_param_h_max" = x"yes"; then
+       AC_DEFINE(HAVE_SYS_PARAM_H_MAX, 1, [Whether sys/param.h declares the MAX macro])
+fi
+
+AC_CACHE_CHECK([for MIN in sys/param.h], samba_cv_sys_param_h_min, [
+       AC_TRY_COMPILE([
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif], [int i = MIN(1,2)],
+       samba_cv_sys_param_h_min=yes, samba_cv_sys_param_h_min=no)] )
+
+if test x"$samba_cv_sys_param_h_min" = x"yes"; then
+       AC_DEFINE(HAVE_SYS_PARAM_H_MIN, 1, [Whether sys/param.h declares the MIN macro])
+fi
 
 AC_TYPE_SIGNAL
 AC_TYPE_UID_T
index e81eec13e9d85300406e7ca438b54dce1f87d022..b79ec33c1ae78167c8176db1d52aa04b4e96c628 100644 (file)
 #include <sys/stat.h>
 
 #ifdef HAVE_SYS_PARAM_H
+/* On (at least) IRIX and Linux, sys/param.h unconditionally defines the MAX
+ * and MIN macros. Since smb_macros.h might have already defined this, we
+ * choose to use the system versions if they are present. This avoids a MIPSPro
+ * compiler warning whenever this file is included.
+ */
+#if defined(HAVE_SYS_PARAM_H_MIN) && defined(MIN)
+#undef MIN
+#endif
+#if defined(HAVE_SYS_PARAM_H_MAX) && defined(MAX)
+#undef MAX
+#endif
 #include <sys/param.h>
 #endif