added #ifdef __cplusplus directives around the extern C declaration