I have downloaded code written in C, I've written a CMakeLists.txt to access it through Eclipse and it works fine and compiles.
My personal code is written in C++. I want to call the C code from it, and I've also created the CMakeLists.txt that takes into account where the C code is.
When I build my project there's no problem, as long as I don't do the following instruction :
// In one of my project's .cpp :
#ifdef __cplusplus
extern "C" {
#endif
#include "C_header_file_I_need.h"
#ifdef __cplusplus
}
#endif
// Core of the .cpp
The errors given tell me that the program is attempting to compile the C code with the C++ compiler and therefore :
nested functions
void*
- ...
are not accepted by the compiler.
I've considered adapting the C program, but it is a lot of work ...
Since it's one compiler per CMakeLists, I was wondering how I could be able to compile the two parts of my project independently and the link them, by using CMakeLists (because I need it to work on any platform).
Thank you for you help, and do not hesitate to tell me what file/log you would need to look at.