You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2008/07/30 22:21:23 UTC

svn commit: r681193 - /incubator/qpid/trunk/qpid/cpp/src/qpid/sys/posix/StrError.cpp

Author: astitcher
Date: Wed Jul 30 13:21:23 2008
New Revision: 681193

URL: http://svn.apache.org/viewvc?rev=681193&view=rev
Log:
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

Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/sys/posix/StrError.cpp

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/sys/posix/StrError.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/sys/posix/StrError.cpp?rev=681193&r1=681192&r2=681193&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/sys/posix/StrError.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/sys/posix/StrError.cpp Wed Jul 30 13:21:23 2008
@@ -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
 }
 
 }}