From dd991f8d3a7808ddf2dedc332507f10cb62e26b5 Mon Sep 17 00:00:00 2001
From: Steven Murray <steven.murray@cern.ch>
Date: Tue, 18 Mar 2014 10:58:52 +0100
Subject: [PATCH] Fixed strerror_r_wrapper() prototype

---
 .../castorrmc/common/strerror_r_wrapper.cpp       |  2 +-
 mediachanger/castorrmc/h/strerror_r_wrapper.h     | 15 ++++++++++++++-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/mediachanger/castorrmc/common/strerror_r_wrapper.cpp b/mediachanger/castorrmc/common/strerror_r_wrapper.cpp
index 77f8670143..09273390d9 100644
--- a/mediachanger/castorrmc/common/strerror_r_wrapper.cpp
+++ b/mediachanger/castorrmc/common/strerror_r_wrapper.cpp
@@ -38,6 +38,6 @@
 /*******************************************************************************
  * strerror_r_wrapper
  ******************************************************************************/
-extern "C" int strerror_r_wrapper(int errnum, char *buf, unsigned int buflen) {
+extern "C" int strerror_r_wrapper(int errnum, char *buf, size_t buflen) {
   return strerror_r(errnum, buf, buflen);
 }
diff --git a/mediachanger/castorrmc/h/strerror_r_wrapper.h b/mediachanger/castorrmc/h/strerror_r_wrapper.h
index 1eaeebf332..059bd065ef 100644
--- a/mediachanger/castorrmc/h/strerror_r_wrapper.h
+++ b/mediachanger/castorrmc/h/strerror_r_wrapper.h
@@ -27,6 +27,19 @@
 
 #include <stddef.h>
 
+/* The following EXTERN_C marco has been intentionally copied from          */
+/* h/osdep.h instead of just including h/osdep.h.  The reason for this is   */
+/* this header file must include the minimum number of header files because */
+/* the implementation file common/strerror_r_wrapper.cpp will undefine      */
+/* _GNU_SOURCE and define _XOPEN_SOURCE as being 600.                       */
+/*                                                                          */
+/* Macros for externalization (UNIX) (J.-D.Durand)                          */
+#if defined(__cplusplus)
+#define EXTERN_C extern "C"
+#else
+#define EXTERN_C extern
+#endif
+
 /**
  * This function wraps the XSI compliant version of strerror_r() and therefore
  * writes the string representation of the specified error number to the
@@ -36,6 +49,6 @@
  * @param buf The buffer.
  * @param buflen The length of the buffer.
  */
-int strerror_r_wrapper(int errnum, char *buf, size_t buflen);
+EXTERN_C int strerror_r_wrapper(int errnum, char *buf, size_t buflen);
 
 #endif /* H_STRERROR_R_WRAPPER_H */
-- 
GitLab