Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > who decides the size of a data type?

Reply
Thread Tools

who decides the size of a data type?

 
 
Richard Heathfield
Guest
Posts: n/a
 
      03-16-2008
Ian Collins said:

> Willem wrote:
>>
>> ) is it plainly the compiler?
>> ) Does OS or Processor also has any control in deciding the size of such
>> ) data types?
>>
>> Usually, the compiler decides the size, based on what the OS and/or
>> the processor have to offer. I think the C standard even strongly
>> suggests that 'int' be the size that is 'most natural' to the system.
>>

> On a hosted environment, the OS dictates the size. In order to work
> with the system's headers and libraries, compilers have to follow the
> platform's standards.


I have a machine here on which are installed several implementations. Most
of these use 32-bit ints, but a couple use 16-bit ints. So is the OS
dictating 16-bit, or 32-bit?

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      03-16-2008
Richard Heathfield wrote:
> Ian Collins said:
>
>> Willem wrote:
>>> ) is it plainly the compiler?
>>> ) Does OS or Processor also has any control in deciding the size of such
>>> ) data types?
>>>
>>> Usually, the compiler decides the size, based on what the OS and/or
>>> the processor have to offer. I think the C standard even strongly
>>> suggests that 'int' be the size that is 'most natural' to the system.
>>>

>> On a hosted environment, the OS dictates the size. In order to work
>> with the system's headers and libraries, compilers have to follow the
>> platform's standards.

>
> I have a machine here on which are installed several implementations. Most
> of these use 32-bit ints, but a couple use 16-bit ints. So is the OS
> dictating 16-bit, or 32-bit?
>

Whichever is required to use the services of the OS.

Any implementation is free to provide its own headers and libraries and
choose its own sizes, but it then restricts its self to building
applications that do not use any external services provided by the OS.

--
Ian Collins.
 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      03-16-2008
Lew Pitcher wrote:
> Ian Collins wrote:
>
>> Willem wrote:
>>> ) is it plainly the compiler?
>>> ) Does OS or Processor also has any control in deciding the size of such
>>> ) data types?
>>>
>>> Usually, the compiler decides the size, based on what the OS and/or
>>> the processor have to offer. I think the C standard even strongly
>>> suggests that 'int' be the size that is 'most natural' to the system.
>>>

>> On a hosted environment, the OS dictates the size. In order to work
>> with the system's headers and libraries, compilers have to follow the
>> platform's standards.

>
> But this may become a "chicken-and-egg" problem on certain platforms, where
> the OS is easily rebuilt with a conforming C compiler (i.e. recompiling a
> 32bit OS into a 64bit OS using a suitable compiler on a 32bit system).
> Additionally, some platforms support multiple concurrent "views" of the
> environment, such that two or more distinct size choices are available at
> execution time (witness some 64bit platforms that execute /either/ 64bit or
> 32bit code (with corresponding differences in data type sizes)
> simultaneously).
>

They do, but they employ standard models for their 32 and 64 bit
personalities. Providing a compiler for windows that used the LP64
model or a UNIX compiler that used the LLP64 model would be possible,
but pointless.

--
Ian Collins.
 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      03-16-2008
Richard Heathfield wrote:
> Ian Collins said:
>
>> Richard Heathfield wrote:
>>> Ian Collins said:
>>>
>>>> Willem wrote:

> <snip>
>>>>> I think the C standard even strongly
>>>>> suggests that 'int' be the size that is 'most natural' to the system.
>>>>>
>>>> On a hosted environment, the OS dictates the size. In order to work
>>>> with the system's headers and libraries, compilers have to follow the
>>>> platform's standards.
>>> I have a machine here on which are installed several implementations.
>>> Most of these use 32-bit ints, but a couple use 16-bit ints. So is the
>>> OS dictating 16-bit, or 32-bit?
>>>

>> Whichever is required to use the services of the OS.

>
> That'd be all of them, then. Hmmm.
>

That's fine, as long as they use the platform's 16 or 32 bit model(s).

--
Ian Collins.
 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      03-16-2008
Ian Collins said:

> Richard Heathfield wrote:
>> Ian Collins said:
>>
>>> Willem wrote:

<snip>
>>>> I think the C standard even strongly
>>>> suggests that 'int' be the size that is 'most natural' to the system.
>>>>
>>> On a hosted environment, the OS dictates the size. In order to work
>>> with the system's headers and libraries, compilers have to follow the
>>> platform's standards.

>>
>> I have a machine here on which are installed several implementations.
>> Most of these use 32-bit ints, but a couple use 16-bit ints. So is the
>> OS dictating 16-bit, or 32-bit?
>>

> Whichever is required to use the services of the OS.


That'd be all of them, then. Hmmm.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
 
Reply With Quote
 
Gordon Burditt
Guest
Posts: n/a
 
      03-16-2008
>On a hosted environment, the OS dictates the size. In order to work
>with the system's headers and libraries, compilers have to follow the
>platform's standards.


An OS, especially one not written in C in the first place (this
applies to the first version of UNIX, too, which was originally
written in assembly language), may come with *NO* system headers
(at least not in C) and *NO* C-callable libraries (it might instead
use assembly-language macros or routines written in some other
language). In that case, it's up to the C implementor to supply
those headers (possibly translated from another language) and
libraries (possibly just "glue" interface routines). If there's
not a popular C API to the OS, the implementor might have to supply
one.

It can still take guidance from the OS (although the more important
guidance is likely from the CPU architecture). Some systems provide
several different choices on the same OS, particularly with respect
to pointer sizes, and provide different sets of libraries for each.
See, for example, the different MS-DOS memory models, which have
different combinations of 16-bit and 32-bit data and function
pointers. I think some compilers also provide a 32-bit mode with
32-bit ints for MS-DOS. You can't mix compiled or standard code
from different models (implementations): they all have to come from
the same one (non-standard features involving the "near" and "far"
pseudo-keywords made some mixing possible).

 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      03-16-2008
{I you are going to reply to one of my posts, please stop being so
arrogant as to ignore attributions]

Gordon Burditt wrote:
>> On a hosted environment, the OS dictates the size. In order to work
>> with the system's headers and libraries, compilers have to follow the
>> platform's standards.

>
> It can still take guidance from the OS (although the more important
> guidance is likely from the CPU architecture). Some systems provide
> several different choices on the same OS, particularly with respect
> to pointer sizes, and provide different sets of libraries for each.
> See, for example, the different MS-DOS memory models, which have
> different combinations of 16-bit and 32-bit data and function
> pointers. I think some compilers also provide a 32-bit mode with
> 32-bit ints for MS-DOS. You can't mix compiled or standard code
> from different models (implementations): they all have to come from
> the same one (non-standard features involving the "near" and "far"
> pseudo-keywords made some mixing possible).
>

Exactly, the compilers follow the OS.

--
Ian Collins.
 
Reply With Quote
 
Gordon Burditt
Guest
Posts: n/a
 
      03-16-2008
>>> On a hosted environment, the OS dictates the size. In order to work
>>> with the system's headers and libraries, compilers have to follow the
>>> platform's standards.

>>
>> It can still take guidance from the OS (although the more important
>> guidance is likely from the CPU architecture). Some systems provide
>> several different choices on the same OS, particularly with respect
>> to pointer sizes, and provide different sets of libraries for each.
>> See, for example, the different MS-DOS memory models, which have
>> different combinations of 16-bit and 32-bit data and function
>> pointers. I think some compilers also provide a 32-bit mode with
>> 32-bit ints for MS-DOS. You can't mix compiled or standard code
>> from different models (implementations): they all have to come from
>> the same one (non-standard features involving the "near" and "far"
>> pseudo-keywords made some mixing possible).
>>

>Exactly, the compilers follow the OS.


MS-DOS did not provide any C system headers or libraries. It's hard to follow
the OS when the OS doesn't provide direction, which is one reason why so many
different directions were followed by MS-DOS C compilers.
 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      03-16-2008
Who said this?

>>>> On a hosted environment, the OS dictates the size. In order to work
>>>> with the system's headers and libraries, compilers have to follow the
>>>> platform's standards.
>>> It can still take guidance from the OS (although the more important
>>> guidance is likely from the CPU architecture). Some systems provide
>>> several different choices on the same OS, particularly with respect
>>> to pointer sizes, and provide different sets of libraries for each.
>>> See, for example, the different MS-DOS memory models, which have
>>> different combinations of 16-bit and 32-bit data and function
>>> pointers. I think some compilers also provide a 32-bit mode with
>>> 32-bit ints for MS-DOS. You can't mix compiled or standard code
>>> from different models (implementations): they all have to come from
>>> the same one (non-standard features involving the "near" and "far"
>>> pseudo-keywords made some mixing possible).
>>>

>> Exactly, the compilers follow the OS.

>
> MS-DOS did not provide any C system headers or libraries. It's hard to follow
> the OS when the OS doesn't provide direction, which is one reason why so many
> different directions were followed by MS-DOS C compilers.



--
Ian Collins.
 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      03-16-2008
Willem wrote:
> rao wrote:
>
>> On some of the compilers integer size is 2 and on some other it
>> is 4 bytes.

>
> And on some, it is 8. And on very few others, it's another number.
>
>> My doubt is who decides the size of the integer?

>
> In India, do 'doubt' and 'question' translate to the same word ?
> In any case, the right word to use in English is 'question'.


No, Willem. The phrases "I have a doubt" and "my doubt" are quite
ordinary English usage. They are more popular in India than in
most other English speaking areas. I concede that many native
English speakers don't recognize that, but their ignorance is of no
concern. You, apparantly, are Dutch, and have no reason to
recognize the usage.

At any rate, apply my favorite exorcism. Sedulously eschew
obfuscation.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.



--
Posted via a free Usenet account from http://www.teranews.com

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
!! EL EXITO LO DECIDES TU !!! adelmo C Programming 0 12-14-2006 03:31 PM
What happens to ApplicationState if IIS decides to spawn another app domain for an ASP dot net application? newjazzharmony@hotmail.com ASP .Net 4 05-15-2006 05:48 PM
appearance: windows decides what's best melanie Computer Support 3 06-21-2005 01:17 PM
Best Buy Decides all customers are not welcome Justin DVD Video 46 11-24-2004 10:14 PM
Dvd commentaries... who decides? volkischlemiel DVD Video 4 01-21-2004 08:18 PM



Advertisments