Re: How does one get the description of an errno value

Steve Graegert <[email protected]>
Newsgroups org.kernel.vger.linux-c-programming
Message-ID <[email protected]>
Tiago,

You're correct.  MAX_ERRNO is a custom macro being defined elsewhere
and actually expands to to sys_nerr.  I picked that code from some
examples I've prepared some years ago.  Sorry for the inconvenience
but I think you get the idea.  see perror(3) for more info.

	\Steve

--

Steve Graegert
www.graegert.com



On Sun, Mar 15, 2009 at 11:43 AM, Tiago Maluta
<[email protected]> wrote:
> Steve,
>
>> The following code snippet should do it.  It basically sets errno
>> manually and outputs the associated error message.
>>
>> --- BEGIN ---
>>
>> #define _ALL_SOURCE
>>
>> #include <stdio.h>
>> #include <errno.h> /* for _MAX_ERRNO */
>>
>
> I've searched in headers on /usr/include for MAX_ERRNO but not found.
> Where MAX_ERRNO is defined?
>
> A *very* simple workaround was check for "Unknown" word, so I tried:
>
> int main(void) {
>        int i=0;
>        extern int errno;
>        char str[128];
>
>        while (strncmp(str,"Unknown",7)) {
>                sprintf(str,"%s",strerror(i));
>                fprintf(stderr, "%3d", i);
>                errno = i;
>                perror(" ");
>                i++;
>        }
>
>        return (0);
> }
>
>
> But there is "Unknown" between valid error messages.
> I think there is a better way to do it....
>
>
> Best regards,
>
> --tm
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.