proper type cast for c++ compilers