diff --git a/mediachanger/castorrmc/common/strerror_r_wrapper.cpp b/mediachanger/castorrmc/common/strerror_r_wrapper.cpp index 09273390d903b858cddae9528683e3fd431d5221..1a149b226946bfc07bfefbacf1b823672c5d112f 100644 --- a/mediachanger/castorrmc/common/strerror_r_wrapper.cpp +++ b/mediachanger/castorrmc/common/strerror_r_wrapper.cpp @@ -39,5 +39,15 @@ * strerror_r_wrapper ******************************************************************************/ extern "C" int strerror_r_wrapper(int errnum, char *buf, size_t buflen) { + /* This function should be compiled using a C++ compiler and not a C compiler. + * + * C++ compilers are better at spotting whether the GNU version or the + * XSI complicant version of sterror_() is being used. This is because the + * difference between the two versions is their return types. The GNU + * version returns a 'char *' whereas the XSI compliant version returns an + * 'int'. A C compiler may allow the strerror_r() function to return a + * 'char *' and have that 'char *' assigned to an 'int'. A C++ compiler + * usually gives an error if this is tried. + */ 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 059bd065ef404870198daed1997768d52987495a..aa474841a1c2066fba23b7bb89b0b9b0d2a3a440 100644 --- a/mediachanger/castorrmc/h/strerror_r_wrapper.h +++ b/mediachanger/castorrmc/h/strerror_r_wrapper.h @@ -44,6 +44,16 @@ * This function wraps the XSI compliant version of strerror_r() and therefore * writes the string representation of the specified error number to the * specified buffer. + * + * This function should be compiled using a C++ compiler and not a C compiler. + * + * C++ compilers are better at spotting whether the GNU version or the + * XSI complicant version of sterror_() is being used. This is because the + * difference between the two versions is their return types. The GNU + * version returns a 'char *' whereas the XSI compliant version returns an + * 'int'. A C compiler may allow the strerror_r() function to return a + * 'char *' and have that 'char *' assigned to an 'int'. A C++ compiler + * usually gives an error if this is tried. * * @param errnum The error number. * @param buf The buffer.