add M_PI definition

fopen -> fopen_s for MSVC
Revised #ifdef to check for MSVC and WIN32
Undo #ifdef modification