Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
The following code is taken from Advanced Unix Programming by Rochkind. It is an error routine which is to be compiled with other programs. Two external variables - sys_errlist is an array of messages that correspond to the error codes, and sys_nerr is one more than the highest defined subscript in an array.
errno should be tested against sys_nerr before indexing sys_errlist.#include
void syserr(char *msg)
{
extern int errno, sys_nerr;
extern char *sys_errlist[];fprintf(stderr, "ERROR: %s (%d", msg, errno);
if (errno > 0 && errno < sys_nerr)
fprintf(stderr, ";%s)\n", sys_errlist[errno]);
else
fprintf(stderr, ")\n");
exit(1);
}The problem is that I am getting the following error message when I try it with other programs
that need the above. The program is named error.c :error.c:7: conflicting types for 'sys_errlist'
/usr/include/stdio.h:554: previous declaration of 'sys_errlist'There is obviously a conflict between stdio.h and error.c. How to rectify this problem ? I have found this problemn on Red Hat Linux 7.2 when I compile with gcc.
Please reply.
Thank You,
Raghu

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |