I have read this answer but I do not know what to do if I have the two functions in C++ and C have the same name. The C function is already guarded with if #ifdef __cplusplus
in the header file.
so I have in .cpp file
foo (int a, int b)
{
//calling from C
foo (int a, int b, int c)
}
Cheader.h
#ifdef __cplusplus
extern "C" {
#endif
void foo(int a,int b, int c);
#ifdef __cplusplus
}
#endif
file.c
#include "Cheader.h"
void foo(int a,int b, int c)
{
/* ... */
}
C++ header
Cplusplusheader.hpp
void foo(int a, int b);
C++
CplusPlus.cpp
#include "Cplusplus.hpp"
#include "Cheader.h"
void foo(int a, int b)
{
foo(a,b,c); // call C function
// ...
}