strerror_r return value

R

Robert

I'm finding conflicting information about strerror_r. The
manpage says an int is returned, but the prototype in string.h
says char *. How exactly is this function supposed to be used
and verified for correct completion? A quick search seems to
suggest that GNU versions may return char *, while the POSIX
standard says int. What's the recommended method of dealing
with portability issues using this function? Casting to int,
then use the user-supplied errbuf if zero, else a generic
message?

TIA,
Robert
 
D

Default User

Robert said:
I'm finding conflicting information about strerror_r.


Unfortunately, this is the wrong group for this question. That's
because it is not a standard C function. If it is indeed a POSIX one,
then perhaps comp.unix.programmer would be appropriate, or since you
are using gnu, the gnu.gcc.help.




Brian
 
M

Martin Ambuhl

Robert said:
I'm finding conflicting information about strerror_r. The
manpage says an int is returned, but the prototype in string.h
says char *.

strerror(), which exists in C, returns a char*.
On the implementations I have used that have the strerror_r() function,
which is not standard C and therefore off-topic, the char* is returned
via the second argument:
#include <string.h>
char *strerror(int errnum);
int strerror_r(int errnum, char *strerrbuf, size_t buflen);
Your question is not one about C, and belongs in a newsgroup for your
implementation or platform.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,156
Messages
2,570,878
Members
47,408
Latest member
AlenaRay88

Latest Threads

Top