Add extern C blocks in headers to facilitate integration with c++. Also add c++ example and make c example compile without warnings.