Fix some mingw compatibility issues

In many cases pion checks for the MSVC compiler when it really means to be checking if the target is WIN32.

This PR does not fix the config.h file as we have customized it in our environment and cannot test it. Suffice it to say, config.h checks for _MSC_VER and should not. It is also safe for it to be added to the linux config.h since _WIN32 will not be defined.