linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steve Graegert <graegerts@gmail.com>
To: Tiago Maluta <maluta_tiago@yahoo.com.br>
Cc: Angel Tsankov <fn42551@fmi.uni-sofia.bg>,
	linux-c-programming@vger.kernel.org
Subject: Re: How does one get the description of an errno value
Date: Sun, 15 Mar 2009 14:10:21 +0100	[thread overview]
Message-ID: <6a00c8d50903150610i53825905n6e8a2512bd04d567@mail.gmail.com> (raw)
In-Reply-To: <49BCDBBA.3000209@yahoo.com.br>

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
<maluta_tiago@yahoo.com.br> 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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2009-03-15 13:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-15 10:46 How does one get the description of an errno value Angel Tsankov
2009-03-15 11:20 ` Bert Wesarg
2009-03-15 11:20 ` Steve Graegert
2009-03-15 10:43   ` Tiago Maluta
2009-03-15 13:09     ` Sergio Luis
2009-03-15 13:10     ` Steve Graegert [this message]
     [not found]     ` <a913862f0903150619o43657d87q2f45dbdbc7071659@mail.gmail.com>
     [not found]       ` <49BD1E25.4010305@yahoo.com.br>
2009-03-15 18:13         ` Akos Marton
2009-03-16  1:23   ` Jon Mayo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6a00c8d50903150610i53825905n6e8a2512bd04d567@mail.gmail.com \
    --to=graegerts@gmail.com \
    --cc=fn42551@fmi.uni-sofia.bg \
    --cc=linux-c-programming@vger.kernel.org \
    --cc=maluta_tiago@yahoo.com.br \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).