C++ compatibility

Only C++ errors are fixed, no functionality changed