Why did you move it out of #if defined WIN32?
This function is only needed on win32.