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

Sergio Luis <[email protected]>
Newsgroups org.kernel.vger.linux-c-programming
Message-ID <[email protected]>
On Sun, Mar 15, 2009 at 7: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?

you could define it with something like this:

#ifndef MAX_ERRNO
#define MAX_ERRNO 4095
#endif

Sergio

>
> 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.