size of the data types.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zeeshan708
    New Member
    • Aug 2009
    • 25

    size of the data types.

    Is it the compiler that determines the size of the data types (e.g an int is of 2 bytes or of 4 bytes ) or does it depends on the computer's hardware that shall determine the size of the data types.
  • donbock
    Recognized Expert Top Contributor
    • Mar 2008
    • 2427

    #2
    The C Standard speciifes minimum sizes for the integral types. It also specifies relative size, for instance, sizeof(long) must be greater than or equal to sizeof(int).

    The person who implements a particular C compiler has freedom to set the type sizes to anything that satisfies the restrictions imposed by the Standard. However, if the compiler author wants to sell many copies of that compiler then the type sizes will bear some relation to the intrinsic data types supported by the processor.

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      It should also be noted that it is not only the size in terms of bytes in an integer that is Compiler/platform defined but also number of bits in the byte.

      That said I have never worked on a platform that did not have 8 bits in its byte although I am reliably told that platforms with both 7 bits in the byte and 9 bits in the byte have existed.

      Comment

      Working...