Added extern C for C++ compatibility