strerror_r return value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robert

    #1

    strerror_r return value

    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

  • Default User

    #2
    Re: strerror_r return value


    Robert wrote:[color=blue]
    > I'm finding conflicting information about strerror_r.[/color]


    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.progr ammer would be appropriate, or since you
    are using gnu, the gnu.gcc.help.




    Brian

    Comment

    • Martin Ambuhl

      #3
      Re: strerror_r return value

      Robert wrote:[color=blue]
      > I'm finding conflicting information about strerror_r. The
      > manpage says an int is returned, but the prototype in string.h
      > says char *.[/color]

      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.

      Comment

      Working...