Hi,

I am trying to compile an open source code on linux Ubuntu and getting the following error:
conflicting types for ‘strlen’

I am pasting the program in which it is giving me the error :

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "port.h"

/*
 * strstr - find first occurrence of wanted in s
 */

char *                          /* found string, or NULL if none */
strstr(s, wanted)
CONST char *s;
CONST char *wanted;
{
        register CONST char *scan;
        register SIZET len;
        register char firstc;
        extern int strncmp();
        extern SIZET strlen(const char *);

        /*
         * The odd placement of the two tests is so "" is findable.
         * Also, we inline the first char for speed.
         * The ++ on scan has been moved down for optimization.
         */
        firstc = *wanted;
        len = strlen(wanted);
        for (scan = s; *scan != firstc || strncmp(scan, wanted, len) != 0; )
                if (*scan++ == '\0')
                        return NULL;
        return scan;
}

I cannot figure out why is this error coming and how to resolve it.
Any help is appreciated.

Thanks

Delete line 19 because the prototype on that line is probably not the same as the prototype found in string.h. Why prototype something twice ?

Thanks for your reply. That error got resolved but now I am having another error.

I am pasting the output after compilation:

lint -I../include  '-DCADROOT="~octtools"' -Cport -n dummy.c memccpy.c memchr.c memcmp.c memcpy.c memset.c strcat.c strchr.c strcmp.c strcpy.c strcspn.c strerror.c strlen.c strncat.c strncmp.c strncpy.c strpbrk.c strrchr.c strspn.c strstr.c strtok.c
make[1]: lint: Command not found
make[1]: *** [llib-lport.ln] Error 127

Why is this error coming....Thanks

Delete line 19 because the prototype on that line is probably not the same as the prototype found in string.h. Why prototype something twice ?

Where did you get this? You must be an archaeologist. The code truly belongs to the past millenium.

The error comes from make, which tries to call lint. Lint is morally obsolete tool (again from seventies), which purpose was to validate the program syntax in such details the old compilers didn't bother to check. You have two choices. Either edit a makefile to remove the lint invocation, or do another digging session to find and install lint.

Comments
LOL
Haven't used lint for over 25 years :)
This article has been dead for over six months. Start a new discussion instead.