Worst side effects from chars signedness. (Explanation of signedness effects on chars and casts)

Posted by JustSmith on Stack Overflow See other posts from Stack Overflow or by JustSmith
Published on 2010-02-03T15:05:03Z Indexed on 2010/06/12 7:23 UTC
Read the original article Hit count: 271

Filed under:
|
|
|

I frequently work with libraries that use char when working with bytes in C++. The alternative is to define a "Byte" as unsigned char but that not the standard they decided to use. I frequently pass bytes from C# into the C++ dlls and cast them to char to work with the library.

When casting ints to chars or chars to other simple types what are some of the side effects that can occur. Specifically, when has this broken code that you have worked on and how did you find out it was because of the char signedness?

Lucky i haven't run into this in my code, used a char signed casting trick back in an embedded systems class in school. I'm looking to better understand the issue since I feel it is relevant to the work I am doing.

© Stack Overflow or respective owner

Related posts about c++

Related posts about debugging