byte RSV_Resp_test[3] = {'a', 'b', 0};

produces the error

error: invalid cast from type 'byte {aka unsigned char}' to type 'char'

How can this be an ill-formed cast? I just need to print the value as a ascii character, not as a number.


works. I still don't understand why the reinterpret_cast errors out.

  • This may help shed light on it: stackoverflow.com/questions/332030/… - summary: static_cast is what you normally want in 99% of situations and is what you need here. reinterpret_cast is only used when you want to do really strange things. – Majenko May 11 '17 at 20:44
  • In a bit of standardization weirdness, section 5.2.10 [expr.reinterpret.cast] says only certain kinds of reinterpret casts are allowed!? Maybe it is time to move back to 'C'. – Gregg May 12 '17 at 12:30
  • Personally I never use them and just use (char)varname instead. – Majenko May 12 '17 at 12:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.