[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [OT] Re: Bug#169450: wrong assumption on char signedness



On 19-Nov-02, 12:35 (CST), Emile van Bergen <emile-deb@evbergen.xs4all.nl> wrote: 
> Or just declare it explicitly as a signed char.

If it's character data, then the proper type is 'char'. If it's integer
data, the proper type is 'short', 'int', or 'long', and unless you've
got specific memory limitations or range requirements, your best bet is
'int'.

If, for some weird reason, you absolutely must have a signed 8-bit
arithmetic type, the proper type is 'int8_t' (found in 'stdint.h'[1]).
Not char. Not signed char[2].

Steve

[1] Yes, stdint.h is C99, but it's already on many systems, doesn't
require actual compiler support, and is trival to implement
(http://www.lysator.liu.se/c/q8/index.html)

[2] The fact that int8_t is often, perhaps even usually, a typedef for
'signed char' doesn't change that.

-- 
Steve Greenland

    The irony is that Bill Gates claims to be making a stable operating
    system and Linus Torvalds claims to be trying to take over the
    world.       -- seen on the net



Reply to: