added extern C for C++ compilers