I have previously written an overloaded function in C++ code and I now need to call that function from a C file. Unfortunately, after I include the c++ header in C, Makefile does not compile. (Am using g++ w/ c++11 flag)
Here are my questions:
Is the program not compiling because C does not support function overloading?
If (1) is the case, what are some other options I can take to use the overloaded function?
cplusplus.h
#ifndef CPLUSPLUS_H
#define CPLUSPLUS_H
#ifdef __cplusplus
extern "C" {
"#endif"
void Foo(A a);
void Foo(B b);
#ifdef __cplusplus
}
"#endif"
cplusplus.cxx
#include "cplusplus.h"
extern "C" {
void Foo(A a) {
print(a.some_member);
}
void Foo(B b) {
print(b.some_member);
}
}
main.c
#include "cplusplus.h"
int main(int argc, char*argv[]) {
return 0; //Even without calling the function, an error throws.
}