Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   C Primitive Data Type Sizes (http://www.velocityreviews.com/forums/t438605-c-primitive-data-type-sizes.html)

Kip 07-04-2005 10:46 PM

C Primitive Data Type Sizes
 
Greetings everyone,

Is there anyone here who could point me to a page or pdf that has a
list of the sizes of all of the C primitive data types on various
implementations such as SPARC, x86, PowerPC, etc?

Thank you.

--
Kip Warner
Vertigo
http://TheVertigo.com

Walter Roberson 07-04-2005 11:50 PM

Re: C Primitive Data Type Sizes
 
In article <xn0e4cngwaay7w001@news.telus.net>,
Kip <Kip_NOSPAM_@TheVertigo.com> wrote:
>Is there anyone here who could point me to a page or pdf that has a
>list of the sizes of all of the C primitive data types on various
>implementations such as SPARC, x86, PowerPC, etc?


You listed chips, but C primitive types can be (and often
have been) implimented in library code.

The size of C primitive types is dependant on the compiler...
which usually takes hints from the underlying hardware, but is
not bound by it.
--
Usenet is like a slice of lemon, wrapped around a large gold brick.

Kip 07-04-2005 11:58 PM

Re: C Primitive Data Type Sizes
 
Walter Roberson wrote:

> In article <xn0e4cngwaay7w001@news.telus.net>,
> Kip <Kip_NOSPAM_@TheVertigo.com> wrote:
> > Is there anyone here who could point me to a page or pdf that has a
> > list of the sizes of all of the C primitive data types on various
> > implementations such as SPARC, x86, PowerPC, etc?

>
> You listed chips, but C primitive types can be (and often
> have been) implimented in library code.
>
> The size of C primitive types is dependant on the compiler...
> which usually takes hints from the underlying hardware, but is
> not bound by it.


Thanks. But it still begs the question of whether or not anyone here
could point me to a page or pdf that has a list of the sizes on all of
the C primitive data types on various implementations?

--
Kip Warner
Vertigo
http://TheVertigo.com

James McIninch 07-05-2005 01:47 AM

Re: C Primitive Data Type Sizes
 
<posted & mailed>

No. The sizes are dependent not only on the processor, but also the
operating environment and, in some cases, the compiler used. Consult the
compiler documentation for each that you are interested in.


Kip wrote:

> Greetings everyone,
>
> Is there anyone here who could point me to a page or pdf that has a
> list of the sizes of all of the C primitive data types on various
> implementations such as SPARC, x86, PowerPC, etc?
>
> Thank you.
>


--
Remove '.nospam' from e-mail address to reply by e-mail

Me 07-05-2005 03:36 AM

Re: C Primitive Data Type Sizes
 
> Is there anyone here who could point me to a page or pdf that has a
> list of the sizes of all of the C primitive data types on various
> implementations such as SPARC, x86, PowerPC, etc?


The answer to your question is probably meaningless for what you're
trying to determine anyway (other than knowing about the data types of
existing C implementations, which is a bad question to ask IMHO).
Knowing the size of primitive data types tells you nothing about them
except how much space they take up in relation to a char. It doesn't
tell you anything about how many padding bits a type has, what encoding
it uses for signed integers, alignment requirements, bit ordering, trap
representations, etc. And an implementation of C doesn't depend on the
underlying hardware, it depends on the C compiler and whatever possible
modes it supports. It's entirely possible for it to emulate 9-bit chars
on an 8-bit machine for example. Why would it do something like that?
Well because it's free to do so and it helps debug non-portable
assumptions about C for those of us that prefer to write code according
to what the standard guarantees a conforming implementation must
support.


Lawrence Kirby 07-05-2005 09:42 AM

Re: C Primitive Data Type Sizes
 
On Mon, 04 Jul 2005 23:58:28 +0000, Kip wrote:

....

> Thanks. But it still begs the question of whether or not anyone here
> could point me to a page or pdf that has a list of the sizes on all of
> the C primitive data types on various implementations?


I don't know of such a list offhand. I'm curious to know however what you
would use such a list for if you find one.

Lawrence


Chris Hills 07-05-2005 09:46 AM

Re: C Primitive Data Type Sizes
 
In article <xn0e4cpclcvq7b002@news.telus.net>, Kip
<Kip_NOSPAM_@TheVertigo.com> writes
>Walter Roberson wrote:
>
>> In article <xn0e4cngwaay7w001@news.telus.net>,
>> Kip <Kip_NOSPAM_@TheVertigo.com> wrote:
>> > Is there anyone here who could point me to a page or pdf that has a
>> > list of the sizes of all of the C primitive data types on various
>> > implementations such as SPARC, x86, PowerPC, etc?

>>
>> You listed chips, but C primitive types can be (and often
>> have been) implimented in library code.
>>
>> The size of C primitive types is dependant on the compiler...
>> which usually takes hints from the underlying hardware, but is
>> not bound by it.

>
>Thanks. But it still begs the question of whether or not anyone here
>could point me to a page or pdf that has a list of the sizes on all of
>the C primitive data types on various implementations?


I doubt such a list exists.

start with:- Char 3,4,5,6,7,8,9 bits and go down hill from there :-)
the problem is that there are very many architectures still in use if
not common.

type pdp11 vax 68000 Cray-2 Unisys Harris 80386
series family 1100 H800

char 8 8 8 8 9 8 8
short 8 8/16 16/16 64(32) 18 24 8/16
int 16 16/32 16/32 64(32) 36 24 16/32
long 32 32 32 64 36 48 32
char * 16 32 32 64 72 24 16/32/48
int * 16 32 32 64(24) 72 24 16/32/64
int (*) 16 32 32 64 56 24 16/32/64




This list is not exhaustive by a LONG LONG way. :-(




Walter Roberson 07-05-2005 04:51 PM

Re: C Primitive Data Type Sizes
 
In article <HAozzcCrblyCFAj1@phaedsys.demon.co.uk>,
Chris Hills <chris@phaedsys.demon.co.uk> wrote:
>In article <xn0e4cpclcvq7b002@news.telus.net>, Kip
><Kip_NOSPAM_@TheVertigo.com> writes


>>Thanks. But it still begs the question of whether or not anyone here
>>could point me to a page or pdf that has a list of the sizes on all of
>>the C primitive data types on various implementations?


>I doubt such a list exists.


>start with:- Char 3,4,5,6,7,8,9 bits and go down hill from there :-)


Though fortunately char sizes smaller than 8 are not compatible with
the standards, so we do not have to worry about those cases when dealing
with standard C. (One might have to worry about them if one is
writing for a version of C adapted for a specialized processor.)


>the problem is that there are very many architectures still in use if
>not common.


And the answer can depend on how one compiles...

>type pdp11 vax 68000 Cray-2 Unisys Harris 80386
> series family 1100 H800



I hope that examing this table of one signal OS's processor family
will convince Kip that in listing major chips lines, he is asking the
wrong question.


SGI, MIPS chips, compiled with SGI's cc compilers in -coff mode
char 8, short 16, int 32, long 32, char * 32, int * 32, int (*) 32

R2000 - IRIX 2, IRIX 3.1, IRIX 3.2
R3000 - IRIX 3.2, IRIX 3.3, IRIX 4.*, IRIX 5.*
R4000 - IRIX 4.0.3 - IRIX 5.*
R4400 - IRIX 5.3
R4600PC - IRIX 5.2 for Indy R4600PC & Challenge S, IRIX 5.3
R4600SC - IRIX 5.2 for Indy R4600SC/XZ & Presenter, IRIX 5.3
R5000 - IRIX 5.3
R8000 - IRIX 6.0, IRIX 6.1
R10000 - not supported
R12000 - not supported
R14000 - not supported


SGI, MIPS chips, compiled with SGI's cc compilers in -o32 mode or -n32 mode
char 8, short 16, int 32, long 32, char * 32, int * 32, int (*) 32
(Note: -o32 mode does not support any 64 bit system calls such as stat64()
or lseek64(), and file sizes are limited to 2 GB. -n32 mode does not
have these restrictions.)

R2000 - not supported
R3000 - not supported
R4000 - IRIX 6.2*, IRIX 6.5 - IRIX 6.5.13-ish
R4400 - IRIX 6.2*, IRIX 6.5 - IRIX 6.5.22
R4600PC - IRIX 6.2*, IRIX 6.5 - IRIX 6.5.?
R4600SC - IRIX 6.2*, IRIX 6.5 - IRIX 6.5.?
R5000 - IRIX 5.3 for R5000 Indy, IRIX 5.3 Indy R5000 with XFS, IRIX 6.2,
IRIX 6.3, IRIX 6.5 - IRIX 6.5.22
R8000 - IRIX 6.0*, IRIX 6.1, IRIX 6.5
R10000 - IRIX 6.2, IRIX 6.5.*
R12000 - early IRIX 6.5.* onward
R14000 - somewhere near IRIX 6.5.17 onward
R16000 - somewhere near IRIX 6.5.23 onward


SGI, MIPS chips, compiled with SGI's cc compilers in -64 mode
char 8, short 16, int 32, long 64, char * 64, int * 64, int (*) 64

R2000 - not supported
R3000 - not supported
R4000 - not supported.
Note: the R4000 has full support for 64 bit arithmetic, and was
-designed- to support 64 bit pointers, but it had a bug in the chip mask
that made 64 bit pointers impractical.
R4400 - IRIX 6.2, IRIX 6.5 - IRIX 6.5.22
R4600PC - not supported
R4600SC - not supported
R5000 - not supported
R8000 - IRIX 6.1, IRIX 6.5 - IRIX 6.5.22
R10000 - IRIX 6.2, IRIX 6.4, IRIX 6.5*
R12000 - early IRIX 6.5.* onward
R14000 - somewhere near IRIX 6.5.17 onward
R16000 - somewhere near IRIX 6.5.23 onward
--
"Never install telephone wiring during a lightning storm." -- Linksys

Chris Croughton 07-05-2005 08:11 PM

Re: C Primitive Data Type Sizes
 
On Tue, 5 Jul 2005 10:46:19 +0100, Chris Hills
<chris@phaedsys.org> wrote:

> start with:- Char 3,4,5,6,7,8,9 bits and go down hill from there :-)


Er, char can only be 8 bits or more (at least in standard C). But my
favourite implementation of the DS9000 has char as 11 bits:

sizeof short 2
sizeof int 3
sizeof long 5
sizeof long long 7

> the problem is that there are very many architectures still in use if
> not common.
>
> type pdp11 vax 68000 Cray-2 Unisys Harris 80386
> series family 1100 H800
>
> char 8 8 8 8 9 8 8
> short 8 8/16 16/16 64(32) 18 24 8/16


8 bit short is not allowed by the standard.

> int 16 16/32 16/32 64(32) 36 24 16/32
> long 32 32 32 64 36 48 32
> char * 16 32 32 64 72 24 16/32/48


Which 80386 compiler has 48 bit char pointers? Just curious...

> int * 16 32 32 64(24) 72 24 16/32/64
> int (*) 16 32 32 64 56 24 16/32/64
>
> This list is not exhaustive by a LONG LONG way. :-(


Or even a long double way <g>...

Chris C

Gordon Burditt 07-05-2005 09:37 PM

Re: C Primitive Data Type Sizes
 
>> type pdp11 vax 68000 Cray-2 Unisys Harris 80386
>> series family 1100 H800
>>
>> char * 16 32 32 64 72 24 16/32/48

>
>Which 80386 compiler has 48 bit char pointers? Just curious...


Any large-model 32-bit-mode i*86 compiler would need this, so you're
not limited to only 4GB code or only 4GB data (the pointer includes
the segment register, for a total of 48 bits). As to whether there
actually are any on the market, I'm not sure.

Gordon L. Burditt


All times are GMT. The time now is 08:50 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.