sizeof(int) 
Author Message
 sizeof(int)

How does sizeof(int) varies on different platforms?. Is it in any way
related to the sizeof pointer variable?


Mon, 05 Nov 2001 03:00:00 GMT  
 sizeof(int)


Quote:
>How does sizeof(int) varies on different platforms?. Is it in any way

Each platform is allowed to choose an appropriate size for int. The
only significant constraint is that int must be able to represent
values in at least the range -32767 to 32767. That in effect means that
it must be at least 16 bits wide.

Quote:
>related to the sizeof pointer variable?

No, the sizes of integers and pointers are unrelated. Pointers could
be narrower than int or wider than long. There is no guarantee that
any integer type exists that can usefully hold the value of a pointer.
Also consider that different pointer types can have different representations
and sizes. On some archetectures which are only "word" addressible char *
pointers are wider than other pointers such as int *. On others (notably
old 16 bits DOS memory models) pointers to objects can be made narrower,
wider or the same size as function pointers.

--
-----------------------------------------


-----------------------------------------



Mon, 05 Nov 2001 03:00:00 GMT  
 sizeof(int)

Quote:
>How does sizeof(int) varies on different platforms?.

By integral multiples of sizeof(char) (sizeof(char) is the quantum
of all C types).

Quote:
>Is it in any way
>related to the sizeof pointer variable?

The sizeof() result of the pointer variable must fit in an integer
type.

A happy relationship may exist where integers and pointers could
be converted back and forth, but this is not necessarily so; the
representation may be different, or one simply might not fit in
the other.

--
Craig

Manchester, NH
We're gonna rock this country/Right out of this world. -- Shania Twain
I've been clean and sober for over a decade. -- Dana Plato



Tue, 06 Nov 2001 03:00:00 GMT  
 sizeof(int)

Quote:
> How does sizeof(int) varies on different platforms?

An int reflects the ``natural size'' for the type on a given execution
environment. Of course, it is constrained to be capable to contain any
value in the range INT_MIN to INT_MIN.

Quote:
> Is it in any way related to the sizeof pointer variable?

No, in spite of legacy code where assumptions were made about the
relationship between int and pointers (including assigning an address
to an int).

Furthermore, the size of different pointers types may vary on the same
execution environment. (Non-standard extensions to C, notably in DOS,
allowed the programmer to determine the size of pointer types with
``near'' and ``far'' modifiers and such bletchery as ``memory models'').

--
========================================================================

      http://www.oldradio.com/archives/nelson/open-computing.html
``Those who don't understand UNIX are condemned to reinvent it, poorly.''



Tue, 06 Nov 2001 03:00:00 GMT  
 sizeof(int)
Groovy hepcat B T Meledom was jivin' on Thu, 20 May 1999 18:39:34
+0530 in comp.lang.c.
sizeof(int)'s a cool scene! Dig it!

Quote:
>How does sizeof(int) varies on different platforms?. Is it in any way
>related to the sizeof pointer variable?

  No. An int is generally the most efficient sized data type on any
given platform. Different hardware, naturally, has different
properties; thus different data sizes are more or less efficient than
others on different platforms. Clear as mud?
--

----- Dig the EVEN NEWER, MORE IMPROVED news sig!! -----

-------------- Shaggy was here! ---------------
    http://aardvark.apana.org.au/~phaywood/
============= Ain't I'm a dawg!! ==============



Sat, 10 Nov 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. relation between sizeof(void*), sizeof(int)

2. sizeof(int) sizeof(long) etc.

3. /Wp64 and sizeof int question

4. Why not sizeof int?

5. how to modify a pointer to an array one sizeof(int)

6. Sizeof int

7. sizeof int

8. sizeof(int)

9. sizeof(int) on 16-bit Atari ST.

10. sizeof int < 32

11. sizeof(int) fails when there's a void * nearby...?

12. Basic question on sizeOf variables int, long

 

 
Powered by phpBB® Forum Software