gcc compatibility:

fix 'error: must #include <typeinfo> before using typeid'
fix 'error: ‘memcpy’ was not declared in this scope'