Replace C cast with macros