- fixing various issues for building under visual studio

 -- fixed min/max redefined warnings
 -- including platform.h for round under visual studio
 -- fixing consistency of const modifiers between function declaration and definition
 -- moving local definitions to top of function to build under visual studio (not c99 compliant)