Skip to content
Snippets Groups Projects
Commit bef9f6d6 authored by Steven Murray's avatar Steven Murray Committed by Steven Murray
Browse files

Improved the comments surrounding strerror_r_wrapper()

parent 865a4e4c
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......@@ -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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment