[Y-devel] ucs4 in wchar_t

Chris Amshey ychris at amshey.net
Thu Feb 26 10:10:15 GMT 2004


On Thu, Feb 26, 2004 at 11:20:05AM +0200, Alexey Boyko wrote:
> 
> > :o) I've seen platforms where int and long are the same size :p (why
> > have a long type ?)
> 
> But I've seen platforms, where int and long have different size.
> 

On platforms where there are 'large number' math instructions, long will
generally be that length, and int will be the natural word length (or
natural math operation length, anyway), but if there's no 'large number'
operand or performance is better with the 'large' than the 'small' number
operand, long and int end up being the same size, because this makes more
sense than having the compiler mask out bits just to make them different.

They both have to exist because they're both defined by the C standard(s),
and many old pieces of code use 'long' all over the place because they 
needed 32 bit math. Today, 32 bit ints are everywhere, and longs are 
unreliable in whether they're 32 or 64 bits, but that's the way it goes.

The only thing you can count on is that sizeof(char) is 1. This does not
mean that a char is only 8 bits however... just that however long char is,
that's the standard 'sizeof' unit measurement in that compiler... fun, yes? ;)

--Chris



More information about the Y-devel mailing list









2026 © www.Y-Windows.Org - All Rights Reserved