Interfacing with c and platform dependent sizes

Steven Schveighoffer schveiguy at yahoo.com
Fri Feb 25 19:24:10 PST 2011


On Fri, 25 Feb 2011 20:06:04 -0500, bearophile <bearophileHUGS at lycos.com>  
wrote:

> simendsjo:
>
>> So.. A long in C is the same as the platform size? And long long doesn't
>> exist in 64 bit?
>
> In D the size of int/uint is 32 bits and long/ulong is 64 bits.
>
> In C the size of int, unsigned int, long, long long int, unsigned long  
> long int, etc are not fixed, the change according to the CPU.  
> sizeof(int) <= sizeof(long) <= sizeof(long long).

It's *recommended* that ints be the size of a standard register.  So,  
those sizes do not have to follow the CPU architecture, and compilers  
could potentially use different sizes even on the same platform.

D (and most languages that came after C) did a much better job on this.

BTW, I think long long is a gnu extension, it's not standard C (I don't  
think long long exists in Visual C for instance).

-Steve


More information about the Digitalmars-d-learn mailing list