From 853c549269efe73d1f4931d305dd37985f0bc1bc Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Wed, 30 Jul 2008 20:21:23 +0000 Subject: 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/qpid@681193 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/sys/posix/StrError.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'cpp') diff --git a/cpp/src/qpid/sys/posix/StrError.cpp b/cpp/src/qpid/sys/posix/StrError.cpp index deb2fca7eb..633e20213c 100644 --- a/cpp/src/qpid/sys/posix/StrError.cpp +++ b/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 -#undef _XOPEN_SOURCE -#else -#include -#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 } }} -- cgit v1.2.1