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

Re: amd64: why is sizeof(int) =4? why not =8?



On Wed, 2006-04-05 at 16:06 -0500, Mitchell Laks wrote:
> On Wednesday 05 April 2006 09:45, Ron Johnson wrote:
> > On Wed, 2006-04-05 at 06:48 -0500, Mitchell Laks wrote:
[snip]
> > AMD decided that, to help with compatibility with s/w written when
> > sloppy programmers assumed that sizeof(int) == sizeof(*), integers
> > will be 32 bits, even in 64 bit mode.
> 
> Thank You !!!!!!!!!!!!! Now I see indeed! when i do 
> 
> int * pointer;
> intf("Size of int  * is %d\n",sizeof(pointer ));
> 
> indeed it does print out 8 !!!
> 
> 
> Thanks. You also answered my question on how to program to 64 bit. I just use 
> int64 ie long long. Thanks!!! 

Ray Lanza sent me a helpful email regarding the origins of this
int/long/point scheme.

-- 
-----------------------------------------------------------------
Ron Johnson, Jr.
Jefferson, LA USA

Note to LSU and Valdosta State students: India is not an Arab
country!
http://www.talonnews.com/news/2003/october/1009_college_dems_jind
al.shtml

--- Begin Message ---
On Wed, 2006-04-05 at 09:45, Ron Johnson wrote:
> On Wed, 2006-04-05 at 06:48 -0500, Mitchell Laks wrote:
> > Hi,
> > 
> > I wanted to find out more about amd64, so I installed the debian distro 
> 
> Did you install the 64 bit version?
> 
> > (etch/sid) on my amd64 dual core system. 
>    ^^^^^^^^
> 
> Which one?  Etch or Sid?
> 
> > I wanted to see if it is really 64 bit. So naively i compiled the following 
> > example program I found on the internet:
> > 
> [snip]
> > Size of double is 8
> > 
> > So how do I see the 64 bittness of the operating system if  not this way with 
> > gcc? I would think tha size of int would be 8?
> > uname -a
> > Linux Rashi 2.6.16.1-meshulum-2006-4-5 #1 SMP Wed Apr 5 13:34:46 EDT 2006 
> > x86_64 GNU/Linux
> 
> If you did actually install the 64 bit build, do a sizeof(int *) 
> and you'll see that it is 64 bits.
> 
> AMD decided that, to help with compatibility with s/w written when
> sloppy programmers assumed that sizeof(int) == sizeof(*), integers
> will be 32 bits, even in 64 bit mode.
> 
> 64 bit integers are of type "long long" and int64, which are just
> different names for the same type.
> 
> -- 
> -----------------------------------------------------------------
> Ron Johnson, Jr.
> Jefferson, LA USA
> 
> "Politicians are the same all over. They promise to build a
> bridge where there is no river."
> Nikita Krushchev
> 
> 
> -- 
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
> 
The data model is known as LP64. Long and pointer are 64 bits, int is 32
bits, short is 16 and char is 8.  This data model is a defacto industry
standard established largely by Digital Equipment Corp in the early 90s
with the introduction of UNIX on the Alpha processor family.

	ray
 


--- End Message ---

Reply to: