[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: 32 bit (un)signed int on every system?
From:       "Russ Steffen" <rsteffen () ia ! net>
Date:       1998-03-20 5:35:39
[Download RAW message or body]

On 20-Mar-98, Christian Esken <chris@wallace.ping.de> wrote:
> On Thu, 19 Mar 1998 Burkhard Lehner wrote:
[snip]
> >long / unsigned long   : seems to be 64 bit on DEC alpha
> >int / unsigned int     : can be 16 bit on some systems
> 
> Be assured on every proper *nix system   sizeof(int)=4

Umm, no. The only int size guarantee you get in C/C++ is:

sizeof( [un]signed char ) <= sizeof( [un]signed short ) 
	<= sizeof( [un]signed int ) <= sizeof( [un]signed long ) 
	( <= sizeof( [un]signed long long* ) when supported )

These are the only assumptions you can make and still keep your
code portable. If you really need an int of a particular size, you
should use an autoconf macro or the like to make a header file that
typedefs the right native int.

BTW, there is *no* guarantee that the pointer type will be size compatable
with any integer type.

Russ
-- 
----------------------------------
Russ Steffen
rsteffen@ia.net

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic