Fix type casting bug on windows