From 5ddf9c99ceb81cb2ef3a12989529a3824641c250 Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Thu, 2 Apr 2015 17:09:31 +0200 Subject: [PATCH] Prevent multiple definition of bool,Min(),Max() (MacOS X) --- CHANGES | 4 ++++ config.h.in | 3 +++ configure.in | 10 ++++++++++ mytypes.h | 10 +++++++++- 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 068f5e2..bd202a5 100644 --- a/CHANGES +++ b/CHANGES @@ -315,6 +315,10 @@ porting: Joachim Fenkes provided an new adapted spec file. + Type bool and macros Min and Max are defined by socat which led to + compile errors when they were already provided by build framework. + Thanks to Liyu Liu for providing a patch. + new features: added option max-children that limits the number of concurrent child processes. Thanks to Sam Liddicott for providing the patch. diff --git a/config.h.in b/config.h.in index b02b8c1..43235b9 100644 --- a/config.h.in +++ b/config.h.in @@ -452,6 +452,9 @@ /* is sig_atomic_t declared */ #undef HAVE_TYPE_SIG_ATOMIC_T + +/* is bool already typedef'd? */ +#undef HAVE_TYPE_BOOL /* is socklen_t already typedef'd? */ #undef HAVE_TYPE_SOCKLEN diff --git a/configure.in b/configure.in index 5e04eeb..e60edaf 100644 --- a/configure.in +++ b/configure.in @@ -782,6 +782,16 @@ AC_MSG_RESULT($sc_cv_type_longlong) AC_CHECK_TYPE(sig_atomic_t,AC_DEFINE(HAVE_TYPE_SIG_ATOMIC_T),,[#include "sysincludes.h"]) +AC_MSG_CHECKING(for bool) +AC_CACHE_VAL(sc_cv_type_bool, +[AC_TRY_COMPILE([],[bool b;], +[sc_cv_type_bool=yes], +[sc_cv_type_bool=no])]) +if test $sc_cv_type_bool = yes; then + AC_DEFINE(HAVE_TYPE_BOOL) +fi +AC_MSG_RESULT($sc_cv_type_bool) + # following builtin macro does not check unistd.h and sys/socket.h where # socklen_t might be defined #AC_CHECK_TYPE(socklen_t, int) diff --git a/mytypes.h b/mytypes.h index f625314..23193d5 100644 --- a/mytypes.h +++ b/mytypes.h @@ -1,5 +1,5 @@ /* source: mytypes.h */ -/* Copyright Gerhard Rieger 2001-2006 */ +/* Copyright Gerhard Rieger */ /* Published under the GNU General Public License V.2, see file COPYING */ #ifndef __mytypes_h_included @@ -7,10 +7,18 @@ /* some types and macros I miss in C89 */ +#ifndef HAVE_TYPE_BOOL +# undef bool typedef enum { false, true } bool; +#endif +#ifndef Min #define Min(x,y) ((x)<=(y)?(x):(y)) +#endif + +#ifndef Max #define Max(x,y) ((x)>=(y)?(x):(y)) +#endif #define SOCKADDR_MAX UNIX_PATH_MAX