Updated for MSVC build

Added some conditionals, fixed vcprojects to include added source files,

updated build_headers.bat to hopefully make it less fragile,
changed a few declarations from middle of function to beginning (c
standard)