简体   繁体   中英

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
}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM