2

I am trying to use strerror_r() function for getting error string corresponding to an error code and I am targeting BSD and Linux platforms, but the man page of strerror_r() says:

int strerror_r(int errnum, char *buf, size_t buflen);
                   /* XSI-compliant */

char *strerror_r(int errnum, char *buf, size_t buflen);
                   /* GNU-specific */

So I am not sure of it's compatibility(the XSI compliancy and GNU specific compliancy) on different platforms, I would appreciate if you could help me telling which platforms is it compatible on ? On which platforms I get which version out of the above ?

tkhurana96
  • 919
  • 7
  • 25
  • Possible duplicate of [How to get POSIX strerror\_r instead of GNU version?](http://stackoverflow.com/questions/3052041/how-to-get-posix-strerror-r-instead-of-gnu-version) – Michael Foukarakis Feb 12 '17 at 16:31
  • @MichaelFoukarakis nope not duplicate, the other answer tries to answer how to use POSIX version instead of GNU while this is asking for compatiblity. – Abhinav Gauniyal Feb 12 '17 at 17:11
  • Regarding the function return value, the GNU version, `char` would get promoted to `int` in line with the C Standard. Using that along with a macro wrapper to use either, as in a `#ifdef` that is. – t0mm13b Feb 12 '17 at 21:22
  • @t0mm13b it would be great if can you explain with an example what you are saying. – tkhurana96 Feb 13 '17 at 03:40

0 Answers0