error: previous declaration of ‘sys_errlist’ was here

This is a discussion on error: previous declaration of ‘sys_errlist’ was here within the C Programming forums, part of the General Programming Boards category; hello, Here i solve this error used #include <stdio.h> and #include <errno.h> even though gettin this problem. error: previous declaration ...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    20

    Post error: previous declaration of ‘sys_errlist’ was here

    hello,
    Here i solve this error used #include <stdio.h> and #include <errno.h> even though gettin this problem.

    error: previous declaration of ‘sys_errlist’ was here
    what i did mistake here and what is the answer.
    Code:
    #include <errno.h>
    
    #include <stdio.h>
    #include <unistd.h>
    
    #include <netdb.h>
    
    #include <sys/socket.h>
    
    #include <sys/types.h>
    
    #include <netinet/in.h>
    
    #include <rpc/rpc.h>
    
    #include <rpc/xdr.h>
    
    #include <rpc/pmap_prot.h>
    
    #include <rpc/pmap_clnt.h>
    
    #include <rpcsvc/yp_prot.h>
    
    #include <rpcsvc/ypclnt.h>
    
    #include <signal.h>
    
    #include <setjmp.h>
    
    
    
    /* xxx: these are sometimes defined by .h files as below for getopt.  I'll
    
       fix it later... */
    
    extern int errno;
    
    #ifndef BSD4_4
    
    extern char *sys_errlist[];
    
    #endif
    
    #ifndef INADDR_NONE
    
    #define INADDR_NONE 0xffffffff
    
    #endif
    Code:
    if (!Single)
    
            if ((rc < 0) && (scan_type == s_tcp) && (errno == ECONNREFUSED))
    
    	  continue;
    
          if ((rc < 0) && (scan_type == s_udp))
    
    	continue;
    
    
    
          if (scan_type == s_tcp)
    
             serv = getservbyport(htons(port),"tcp");
    
          else if (scan_type == s_udp) {
    
             serv = getservbyport(htons(port),"udp");
    
    	 rc = 0;	/* fake out below msg */
    
          }
    
          else 
    
             return;
    
          fprintf(stdout,"port &#37;d (%s) %s\n", port,
    
    	(serv == NULL)?"UNKNOWN": serv->s_name,
    
    	(rc == 0) ? "open" : sys_errlist[errno]);
    
          fflush (stdout);
    
       }
    
    }

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    wouldn't strerror() do what you want? It seems like extern declaring sys_errlist[] is bound to fail if it's ever changed.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 11:17 AM
  2. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 08:13 PM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21