[LLVMdev] [cfe-dev] confusion with character types

OvermindDL1 overminddl1 at gmail.com
Thu Oct 14 12:42:43 PDT 2010


On Thu, Oct 14, 2010 at 7:11 AM, Bruce Stephens
<bruce.r.stephens at gmail.com> wrote:
> Jochen Wilhelmy <j.wilhelmy-KvP5wT2u2U0 at public.gmane.org> writes:
>
> [...]
>
>> So my question: Is there a paricular reason why the standard stream
>> interprets signed char and
>> unsigned char as characters instead of numbers?
>
> That seems to me to be the better interpretation.  Specifically, it
> would be surprising (to me) if
>
>        std::cout << "Hello world" << '\n';
>
> caused "Hello world10" to be displayed.

Actually I get what he is saying, '\n' is a char, but unsigned char
and signed char are different types from char, and they should be
distinct from char and displayed as integers, where char should be
displayed as a string.  I always have to remember to display my byte
arrays as hex as:
std::cout << std::hex << static_cast<int>(bytearray[i]) << ' ';

Way too freaking verbose when bytearray is an array of unsigned char's
(typedef'd as byte).




More information about the llvm-dev mailing list