From 81a39f964e5efcbfb9242273e71703ca9151c679 Mon Sep 17 00:00:00 2001 From: James Peach Date: Sun, 22 Jan 2006 23:48:56 +0000 Subject: r13071: Work around a really annoying compiler warning where header file ordering causes MIN and MAX to be redefined. (This used to be commit 0eda8a31975fa6cf4f7026bccc5468fba957860d) --- source4/build/m4/rewrite.m4 | 21 +++++++++++++++++++++ source4/include/system/filesys.h | 11 +++++++++++ 2 files changed, 32 insertions(+) diff --git a/source4/build/m4/rewrite.m4 b/source4/build/m4/rewrite.m4 index 92bcdc0414..0bdd181a55 100644 --- a/source4/build/m4/rewrite.m4 +++ b/source4/build/m4/rewrite.m4 @@ -67,6 +67,27 @@ AC_CHECK_HEADERS(sys/mount.h, , , [AC_INCLUDES_DEFAULT #include #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 +#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 +#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 diff --git a/source4/include/system/filesys.h b/source4/include/system/filesys.h index e81eec13e9..b79ec33c1a 100644 --- a/source4/include/system/filesys.h +++ b/source4/include/system/filesys.h @@ -24,6 +24,17 @@ #include #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 #endif -- cgit