C++ compatibility

Only C++ errors are fixed, no functionality changed.

Code now compatible with Visual Studio 2008. I think it's a good chance to increase number of active developers.
There seems to be at least a few lines like this and I think they could be replaced by `dir = DIR_NONE;`. What do you think?