> From: [email protected] On Behalf Of Darryl Miles
> Sent: Wednesday, 06 October, 2010 20:45

Very minor nits, but since we're being pedantic:

<snip 64bit issues>

> > The rules that you can trust are:
> 
> The ones mandated by the C language.
> 
> [From memory]
> sizeof(char) == 1 (aka 8 bits)

Yes and no. sizeof(char) is always 1. char must be at least 8 bits;
the Standard allows more. In practice on systems that have stdio 
(and thus ftell or similar is relevant) char is exactly 8 bits.

> sizeof(short) >= sizeof(char)
> sizeof(int) >= sizeof(short)
> sizeof(long) >= sizeof(int)
> 
What's actually required is the 'width' (number of bits used to 
represent the value) is nondecreasing in char,short,int,long, 
and in C99 long long. A C implementation can use padding bits 
in addition to the value bits and it's theoretically legal for int 
to have more padding bits than long and thus occupy more storage. 
But any implementor who did this would be tarred and feathered.

> > Oh, and stdint.h is not available with all compilers!
> 
> Isn't this an ANSI requirement, ah well, poor compiler users what 
> standards do they conform to then ?
> 
It's a (new) requirement of C99, which is the official standard 
according to both ANSI (via INCITS) and ISO/IEC JTC1. But almost 
11 years after official adoption C99 is not nearly as widely 
implemented as C89/90 was maybe 2-3 years after its adoptions.
C89 filled a gaping hole that everyone agreed was bad. C99 made 
modest changes that some people don't even agree are improvements.

MSVC++ in particular doesn't even aim for C99 conformance.
GCC does for the core-language part, but GCC doesn't implement 
(most of) the library, relying instead on either glibc or a 
platform library, so GCC+glibc is very nearly conforming 
(modulo bugs, of course) but "GCC" in general may not be.

And of course there are other implementations.



______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [email protected]
Automated List Manager                           [email protected]

Reply via email to