porting to c++