C++ code and objects from C?

c, c++, lisp

Solution

That, in general, is the simplest method.

Remember, too, that you'll need to use `extern "C"` on all of your C "wrapper" methods, as well.

Problem

Is there a simple way to work with C++ objects directly from C? I want to expose some classes from C++ to C or to FFI(foreign function interface). Sure, I can write a stuff like that: ``` class Foo{ .... }; void *make_foo(...){ Foo *ptr = new Foo(..) return static_cast<void *>(ptr); } .. int *foo_method1(void *fooptr, ...){ Foo *ptr = static_cast<Foo*>(fooptr); } ``` But there is a simpler method?

Original source