I am using Linux and I have the following files:
main.c, main.h fileA.c, fileA.h fileB.cpp, fileB.h
The F1() function is declared in fileB.h and is defined in fileB.cpp . I need to use a function in fileA.c , and so I declared this function as
extern void F1();
in fileA.c .
However, during compilation I got an error
fileA.c: (.text+0x2b7): undefined reference to `F1'
What's wrong?
Thanks.
ETA: Thanks to the answers I now have the following:
In file.h I have
#include fileB.h #include main.h #ifdef __cplusplus extern "C" #endif void F1();
In file.c file, I have
#include fileA.h
In fileB.h I have
extern "C" void F1();
In fileB.cpp I have
#include "fileB.h" extern "C" void F1() { }
However now i have an error
fileB.h: error: expected identifier or '(' before string constant
source share