some fixes to scalar.c so they work in MSVC