Sagar
Sagar

Reputation: 9503

Implicit declaration of function in spite of including header file

I have a function myfunc defined in a source file myfunc.c and declared in a header file myfunc.h. Both these files are part of a library.

In another project's (projA) source file, I am including the header file as:

#include "myfunc.h"

and using the function correctly (number of parameters, order, etc).

I've edited the Makefile so it has the path to myfunc.h in it's list of includes (-I).

However, I am still getting a warning about implicit declaration. Since projA has warning = error set, it fails on compilation.

Note: this is not an eclipse issue as here, or a missing header as here, or an undeclared function.

Addendum

int myfunc(char * source, size_t source_len, char * dest, size_t dest_len)
{
    // manipulation
    strncpy(dest, source, dest_len);
    // other stuff
}

Upvotes: 0

Views: 10388

Answers (1)

EyeOfTheHawks
EyeOfTheHawks

Reputation: 576

Take a look at this https://gcc.gnu.org/onlinedocs/cpp/Ifdef.html
You may need to add this in to your Header files to avoid duplicate inclusion

Upvotes: 1

Related Questions