This is what I've used to call non-member functions in C++ from C code and it works fine.
file.cpp
extern "C" void f(int);
void f(int i){
printf("c++!\n");
}
main.c
#include <stdio.h>
#include <stdlib.h>
void f(int);
int main()
{
printf("Hello world!\n");
f(1);
return 0;
}
shell:
Hello world!
c++!
How can I call member functions from C?
When you make code compatible between C and C++, that code must have features common to both languages. This implies, among other things, that the code must not have classes, as well as other elements specific to C++.
If you need C to end up calling C++'s own elements you need to create an API (in C++) that encapsulates all object logic, which is not recognized by C, and allows its manipulation through the use of simple functions.
An example to manage a string. I don't have a C compiler at hand, but except for some small adjustment I understand that it should work