The standard mechanism should look something like this:
mylib.h:
#ifndef __cplusplus
extern "C" {
#endif
void * createThing();
void destroyThing(void *);
// more things to operate on the object
#ifndef __cplusplus
} // extern "C"
#endif
magic_lib.cpp:
#include "magic_thing.hpp"
#include "mylib.h"
void * createThing()
{ return new MagicThing; }
void destroyThing(void * p)
{ delete static_cast<MagicThing *>(p); }
Usage (in C):
#include "mylib.h"
int main(void)
{
void * p = createThing();
// ... use p ...
destroyThing(p);
}
If you don't like void pointers, you could add a type alias like typedef void * ThingHandle
or so.