minor casts and DLLEXPORT fixes for MSVC
Merge pull request #8749 from JuliaLang/tk/minor-msvc-fixups

minor casts and DLLEXPORT fixes for MSVC