Re: Data Types



On Fri, May 25, 2001 at 11:51:02AM +0100, Dave Neary wrote:
> As a pedantic point, there's nothing in the C standard guaranteeing that
> sizeof(int)==sizeof(int *) - CHAR_BIT*sizeof(int) is limited below by
> 32, and that's it. In fact, the sizes of the various types are compiler
> dependant. 

True.

> gcc defines short int as a 16-bit type, int as a 32 bit type, long int
> as a 32 bit type and long long int (which is standard in C99) as it's 64
> bit type. Regardless of the platform. Bottom line: int doesn't have to
> be a 64-bit type on a 64-bit platform, although it can be, dependant on
> the compiler.

No, it depends on the host architecture. From gcc-3.0 CVS, note that
long int is not 32 bits on all architectures:

For Alpha:
#define HOST_BITS_PER_CHAR      8
#define HOST_BITS_PER_SHORT     16
#define HOST_BITS_PER_INT       32
#define HOST_BITS_PER_LONG      64
#define HOST_BITS_PER_LONGLONG  64

For i386:
#define HOST_BITS_PER_CHAR 8
#define HOST_BITS_PER_SHORT 16
#define HOST_BITS_PER_INT 32
#define HOST_BITS_PER_LONG 32
#define HOST_BITS_PER_LONGLONG 64

For TMS320C[34]x:
#define HOST_BITS_PER_CHAR 32
#define HOST_BITS_PER_SHORT 32
#define HOST_BITS_PER_INT 32
#define HOST_BITS_PER_LONG 32
#define HOST_BITS_PER_LONGLONG 64

Gcc usually follows the systems native compiler, but if there isn't a
compiler or if it is too broken to be useful, it uses the most logical
size of datatypes to use.

You are right that int is 32 bit, my fault.


Erik

-- 
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department
of Electrical Engineering, Faculty of Information Technology and Systems,
Delft University of Technology, PO BOX 5031,  2600 GA Delft, The Netherlands
Phone: +31-15-2783635  Fax: +31-15-2781843  Email: J A K Mouw its tudelft nl
WWW: http://www-ict.its.tudelft.nl/~erik/




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