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@xxxxxxxxxxxx> 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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
[Linux Assembler]
[Git]
[Kernel List]
[Fedora Development]
[Fedora Announce]
[Autoconf]
[Yosemite Campsites]
[Yosemite News]
[GCC Help]