Added #ifdef wrapping to prevent double function definitions