diff options
author | Andrew Stitcher <astitcher@apache.org> | 2008-07-30 20:21:23 +0000 |
---|---|---|
committer | Andrew Stitcher <astitcher@apache.org> | 2008-07-30 20:21:23 +0000 |
commit | 352d6c33c0e05ef512298be261424953a4de0983 (patch) | |
tree | a9efc5bc54c9463772fa2c28fadb78a2478195fc | |
parent | d469a7c8812dca1f81c6a48dd2e965d6f8927770 (diff) | |
download | qpid-python-352d6c33c0e05ef512298be261424953a4de0983.tar.gz |
The previous attempt to only get an xpg strerror_r with the GNU failed
instead use the definition of _GNU_SOURCE as a proxy for the gnu version
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@681193 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | qpid/cpp/src/qpid/sys/posix/StrError.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/qpid/cpp/src/qpid/sys/posix/StrError.cpp b/qpid/cpp/src/qpid/sys/posix/StrError.cpp index deb2fca7eb..633e20213c 100644 --- a/qpid/cpp/src/qpid/sys/posix/StrError.cpp +++ b/qpid/cpp/src/qpid/sys/posix/StrError.cpp @@ -21,24 +21,21 @@ #include "qpid/sys/StrError.h" -// Ensure we get the POSIX verion of strerror_r -#ifndef _XOPEN_SOURCE -#define _XOPEN_SOURCE 600 #include <string.h> -#undef _XOPEN_SOURCE -#else -#include <string.h> -#endif - namespace qpid { namespace sys { std::string strError(int err) { - char buf[512]; - //POSIX strerror_r doesn't return the buffer + char buf[512] = "Unknown error"; +#ifdef _GNU_SOURCE + // GNU strerror_r returns the message + return ::strerror_r(err, buf, sizeof(buf)); +#else + // POSIX strerror_r doesn't return the buffer ::strerror_r(err, buf, sizeof(buf)); return std::string(buf); +#endif } }} |