Specific sizes of variable types



Hi all,

I'm writing an application which will be opening binary files with
definite sizes for integers(2 byte integers and 4 byte longs). Is there
a portable way in being sure that each integer will be exactly 2 bytes?
Should I have a platform dependent header file which checks for
CHAR_BIT and sizeof(int) etc and have a few typedefs like int16, long32
etc.
<OT>
If I have to go non-portable, then what's the way to determine the
sizes before compilation and typedef accordingly?
</OT>

Thanks

.



Relevant Pages

  • Re: Specific sizes of variable types
    ... > definite sizes for integers. ... > CHAR_BIT and sizeofetc and have a few typedefs like int16, ... you could be made redundant, ...
    (comp.lang.c)
  • Re: Specific sizes of variable types
    ... I'm writing an application which will be opening binary files with ... definite sizes for integers(2 byte integers and 4 byte longs). ... CHAR_BIT and sizeofetc and have a few typedefs like int16, ...
    (comp.lang.c)
  • Re: Specific sizes of variable types
    ... > definite sizes for integers(2 byte integers and 4 byte longs). ... C99 has a standard header called, which provides typedefs ...
    (comp.lang.c)
  • Re: Specific sizes of variable types
    ... > definite sizes for integers. ... > sizes before compilation and typedef accordingly? ...
    (comp.lang.c)
  • Re: Specific sizes of variable types
    ... You can find out the sizes of types, ... See the 'sizeof' operator. ... The only way before compilation is to read your documentation. ...
    (comp.lang.c)