improved compatibility for inclusion in c++ projects

* wrapped in extern "C" so the raw code can easily be imported for c++ without causing linker errors