|
Boost Testing : |
From: Christopher Cambly (ccambly_at_[hidden])
Date: 2007-09-26 22:48:48
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
is:
"../../../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
error_code.cpp].
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? 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.
--- 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
+#endif
#include <ostream>
+#if defined(_AIX)
+#undef _LINUX_SOURCE_COMPAT
+#endif
+
#include <string>
#include <stdexcept>
#include <functional>
Chris Cambly
XL C++ Compiler Development