implicit declaration of function ‘str[n]casecmp’ [-Werror=implicit-function-declaration]

11,104

Solution 1

These functions are declared in strings.h, not string.h.

Solution 2

include the header strings.h instead of string.h..

Share:
11,104
Homunculus Reticulli
Author by

Homunculus Reticulli

Updated on June 04, 2022

Comments

  • Homunculus Reticulli
    Homunculus Reticulli about 2 years

    I am compiling a C library, using C99. I am including string.h to my translation unit (and I can navigate to the definitions of the str?casecmp functions in my netbeans IDE.

    The source looks something like this:

    #include <string.h>
    
    int foo(char* c1, char* c2) {
       return strcasecmp(c1, c2);
    }
    
    
    int foobar(char* c1, char* c2, int n) {
       return strncasecmp(c1, c2, n);
    }
    

    However, when I attempt to compile, I get the error shown in the title.

    I am using gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5).

    This is what my gcc command looks like:

    gcc    -c -g -Werror -DE4C_THREADSAFE -DLINUX_BUILD -I../include -I../genutils -std=c99 -fPIC  -MMD -MP -MF build/Debug/GNU-Linux-x86/btypes.o.d -o build/Debug/GNU-Linux-x86/btypes.o btypes.c
    

    What is causing this, and how do I fix it?