I'm new to C++ and this is my very first attempt to write C++ to C binding.
Problem: with the code below, i can only create single instance of the set in C. How can I make the variable to create with a new reference address (and keep the other instances) every time i call the function? I had try malloc and memcpy but it doesn't work as C structure does. I suppose it is because of how C++ link the virtual functions. Also returning the local variable doesn't work either (garbage collected?).
Original Definition in C++:
my c wrapper code:Code:typedef std::set<int> int_set;
Code://dummy structure typedef struct int_set int_set; extern "C" void * INT_SET_NEW() { static int_set iset; return &iset; }