I don't know how we got onto this. Back in my PDP11 Unix days, we had 
poorly written code that assumed that ints were 16 bit. I've even seen 
compilers (on the Atari 68000 systems) where shorts were defined as 8 bit. 

The C standards define things by value, which translate to bits.
In C (and C++):
short <= int <= long.
A short must be at least 16 bits, and an int must be as least as bit as a 
short and may be as large as a long. 
There is no maximum size for a long. 

Additionally, the C and C++ languages allow the assignment of pointers to 
integral types and vice-versa. It allso allows for pointer arithmetic. 

On most 64 bit processors, there is an LP64 standard:
Long = 64 bit, Pointers = 64 bit, ints remain at 32 bit. 

If, in the 32 bit world you assign pointers to longs and vice-versa, your 
code will be reasonably portable. (assuming you use unsigned so there is no 
sign extension issues).

On a 32 and 64 bit system:
int *foo;

        foo++;
is equivalent to adding 4 to the pointer foo.

long *foo;
        foo++;
in 32 bits is adding 4 to foo, and on 64 bits, add 8 to foo because a long 
is 8 bytes. 

Casing can also have some interesting problems:
Assume that malloc(3) is NOT prototyped:

char *foo;
        foo = malloc(size);

        On a 32 bit system, this will work even is malloc is not prototyped. On a 
64 bit system it will fail because the compiler will generate an int as the 
return value for malloc(3) and any other non-declared or prototyped 
function. 
On 24 Jun 2002 at 13:49, Bayard Coolidge USG wrote:
> Since then, and more recently with Linux, I've tried to champion the
> concept/mindset that not everything is i386 (or IA32), that there are
> other architectures that it's been/being ported to, and some of them
> are 32 bit and some are 64 bit (and, admittedly, there is more than
> one 64 bit architecture to which it's been ported that is still
> shipping).

--
Jerry Feldman <[EMAIL PROTECTED]>
Associate Director
Boston Linux and Unix user group
http://www.blu.org PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9


*****************************************************************
To unsubscribe from this list, send mail to [EMAIL PROTECTED]
with the text 'unsubscribe gnhlug' in the message body.
*****************************************************************

Reply via email to