Computing.Net > Forums > Linux > Problem compiling C program

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Problem compiling C program

Reply to Message Icon

Name: Raghu
Date: October 12, 2002 at 02:56:16 Pacific
OS: Red Hat Linux 7.2
CPU/Ram: PIII/128 MB
Comment:

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



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: Problem compiling C program

compile C-programs www.computing.net/answers/linux/compile-cprograms/499.html

how to compile c++ www.computing.net/answers/linux/how-to-compile-c/11418.html

problems compiling a program www.computing.net/answers/linux/problems-compiling-a-program/11043.html