Boost Testing :
From: Beman Dawes (bdawes_at_[hidden])
Date: 2007-09-27 13:08:17
Christopher Cambly wrote:
> I'm getting an error compiling system/src/error_code.cpp with IBM XL C/C++
> that started a couple days ago. The error issued from the IBM XL compiler
> "../../../libs/system/src/error_code.cpp", line 211.5: 1540-0240 (S) A
> duplicate case value is not allowed.
> The problem is that AIX /usr/include/errno.h #define's ENOTEMPTY to
> EEXIST causing the duplicate constant-expressions in the case statement.
> The Posix standard seems to require that the values be unique. AIX by
> default treats ENOTEMPTY and EEXIST as the same value. To have AIX define
> the macros ENOTEMPTY and EEXIST with different values one needs to define
> the macro _LINUX_SOURCE_COMPAT. Unfortunately in this case, leaving the
> _LINUX_SOURCE_COMPAT macro defined introduces different declarations for
> some other Posix functions so it also needs to be undef'd [strerror_r()
> gets a non-Posix declaration which causes some problems later on in
> The patch below works, however may not be ideal. I am wondering if there a
> better place in the boost source to make such a change?
This is the third case so far of two POSIX macros being defined as the
same value. The others being EOPNOTSUPP / ENOTSUP and EAGAIN /
EWOULDBLOCK. The recipe we are using to cope is:
# if ENOTEMPTY != EEXIST
case ENOTEMPTY: return make_error_condition( directory_not_empty );
# endif // ENOTEMPTY != EEXIST
The advantage being that it works for any other system that happens to
have done the same thing.
I've committed this change to SVN.
> As an aside, one
> of our developers mentioned that Boost.Filesystem has a similar problem
> with the macros ENOTEMPTY and EEXIST not being unique, however I not
> verified this yet.
Was this in operations.cpp? The code I see there will still work if the
two macros define the same value, unless I'm missing something.
Thanks for the help,
> --- boost/system/error_code.hpp~ 2007-09-21 07:45:23.000000000 -0400
> +++ boost/system/error_code.hpp 2007-09-26 22:23:04.146591954 -0400
> @@ -17,7 +17,14 @@
> #include <boost/operators.hpp>
> #include <boost/noncopyable.hpp>
> #include <boost/utility/enable_if.hpp>
> +#if defined(_AIX)
> +#define _LINUX_SOURCE_COMPAT
> #include <ostream>
> +#if defined(_AIX)
> +#undef _LINUX_SOURCE_COMPAT
> #include <string>
> #include <stdexcept>
> #include <functional>
> Chris Cambly
> XL C++ Compiler Development