I have somу C source files and some CPP source files. I'm trying to call function, written in C from CPP file. For example
filea.c
int apb(int a, int b) { return a+b; }
filea.h
int apb(int a, int b);
fileb.cpp
#include "filea.h" int main(void) { return apb(5,1); }
compiler tells me error: Error: L6218E: Undefined symbol apb(int, int) (referred from fileb.o).
And the question is:
How to make it work?
In your fileb.cpp do:
extern "C" { #include "filea.h" } int main(void) { return apb(5,1); }
This specifies that everything in the 'extern' block has 'C' linkage.
Thanks!!