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

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



On Thu, 2006-04-06 at 10:29 +0000, Miquel van Smoorenburg wrote:
> In article <1144244740.27250.8.camel@haggis.homelan>,
> Ron Johnson  <ron.l.johnson@cox.net> 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.
> 
> Hmm? That's a decision of the GCC guys. They decided to make int
> 32 bits. Remember it's just a C data type.
> 
> It makes sense because this way, you have a standard C data type
> for every size of integer:
> 
> char	8 bit
> short	16 bit
> int	32 bit
> long	64 bit

Thanks to Ray Lanza for reminding me that this is called the LP64
model, developed by DEC for the Alpha and OSF/1.

http://www.unix.org/version2/whatsnew/lp64_wp.html

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

"He was so narrow minded he could see through a keyhole with both
eyes."
Molly Ivins



Reply to: