Fix MinGW casting errors / redefinitions / pointer arithmetic

Fixes integer comparisons to NULL (-Wpointer-arith)
Fixes deprecated string literal implicit conversion (-Wwrite-strings)
Fixes preprocessor redefinitions

I used const_cast<type> for the string literal conversions. Since most of the rest of the code uses C-style casts, we might consider doing that for consistency. However, I believe that using const_cast is the most "proper" C++ way.