Is there is any strong reason not to use standard native C++ data types

Discussion in 'C++' started by Abhishek Saksena, Aug 10, 2005.

  1. Hi all,
    Is there is any strong reason not to use standard C++ native datatypes.
    The only reason I can imagine is protability issuse on different
    machines.But did C++ not gurantee portaibilty of standard native datatypes ?
    Abhishek Saksena, Aug 10, 2005
    #1
    1. Advertising

  2. Abhishek Saksena

    Guest

    hi abhishek,


    no!!!

    c++ dosn't gurantee the size of the native data types.
    it only makes some very weak statements such as the size of int should
    be greater than
    or equal to short but never makes exact statement about the size.

    thanks
    rt.
    , Aug 10, 2005
    #2
    1. Advertising

  3. wrote:

    please leave some context. The question is if C++ guarantees the
    sizes of native data types

    >
    > no!!!
    >
    > c++ dosn't gurantee the size of the native data types.
    > it only makes some very weak statements such as the size of int should
    > be greater than
    > or equal to short but never makes exact statement about the size.


    it does, however, specify a minimum size. A char is at least 8 bits, an
    at leat 16 bits and a long at least 32 bits. There are similar promises
    for floating point types. Unsigned are the same size as their
    corresponding signed types

    --
    Nick keighley
    Nick Keighley, Aug 10, 2005
    #3
  4. Nick Keighley wrote:

    []

    > it does, however, specify a minimum size. A char is at least 8 bits, an
    > at leat 16 bits and a long at least 32 bits. There are similar promises
    > for floating point types. Unsigned are the same size as their
    > corresponding signed types


    It does not.

    It only states that:

    sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long)

    And that "Plain ints have the natural size suggested by the
    architecture of the execution environment".

    Refer to ยง3.9.1/2
    Maxim Yegorushkin, Aug 10, 2005
    #4
  5. Abhishek Saksena

    msalters Guest

    Maxim Yegorushkin schreef:

    > Nick Keighley wrote:
    >
    > []
    >
    > > it does, however, specify a minimum size. A char is at least 8 bits, an
    > > at leat 16 bits and a long at least 32 bits. There are similar promises
    > > for floating point types. Unsigned are the same size as their
    > > corresponding signed types

    >
    > It does not.
    >
    > It only states that:
    >
    > sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long)


    It also states that these must be implemnted in some kind of binary
    system, and that the ranges are at least (-127,127), (-32767,32767)
    and so on. (by reference from C90)
    Those ranges imply additional minimum sizes, as Nick correctly noted.

    HTH,
    Michiel Salters
    msalters, Aug 10, 2005
    #5
  6. msalters wrote:
    > Maxim Yegorushkin schreef:
    >
    > > Nick Keighley wrote:
    > >
    > > []
    > >
    > > > it does, however, specify a minimum size. A char is at least 8 bits, an
    > > > at leat 16 bits and a long at least 32 bits. There are similar promises
    > > > for floating point types. Unsigned are the same size as their
    > > > corresponding signed types

    > >
    > > It does not.
    > >
    > > It only states that:
    > >
    > > sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long)

    >
    > It also states that these must be implemnted in some kind of binary
    > system, and that the ranges are at least (-127,127), (-32767,32767)
    > and so on. (by reference from C90)


    C++ standard does not state that. C does indeed.

    However, Derek M. Jones in his book "The New C Standard" quotes:

    Resolutions Prepared at the Eleventh Plenary Meeting of
    ISO/IEC JTC 1/SC22 Snekkersten, Denmark
    August 24 27, 1998
    Resolution 98-6: Relationship Between the Work of WG21 and that of WG14
    Recognizing that the user communities of the C and C++ languages are
    becoming increasingly divergent, ISO/IEC JTC 1/SC22 authorizes WG21 to
    carry out future revisions of ISO/IEC 14882:1998 (Programming Language
    C++) without necessarily adopting new C language features contained in
    the current revision to ISO/IEC 9899:1990 (Programming Language C) or
    any future revisions thereof.
    ISO/IEC JTC 1/SC22 encourages WG14 and WG21 to continue their close
    cooperation in the future.
    Maxim Yegorushkin, Aug 10, 2005
    #6
  7. Abhishek Saksena

    Pete Becker Guest

    Re: Is there is any strong reason not to use standard native C++data types

    Maxim Yegorushkin wrote:
    > msalters wrote:
    >
    >>
    >>It also states that these must be implemnted in some kind of binary
    >>system, and that the ranges are at least (-127,127), (-32767,32767)
    >>and so on. (by reference from C90)

    >
    >
    > C++ standard does not state that. C does indeed.
    >


    C90 imposes those minimum ranges through the requirements on CHAR_MIN,
    etc. as specified in <limits.h>. C++ incorporates those requirements
    through <climits>.

    --

    Pete Becker
    Dinkumware, Ltd. (http://www.dinkumware.com)
    Pete Becker, Aug 10, 2005
    #7
  8. Pete Becker wrote:

    []

    > > C++ standard does not state that. C does indeed.
    > >

    >
    > C90 imposes those minimum ranges through the requirements on CHAR_MIN,
    > etc. as specified in <limits.h>. C++ incorporates those requirements
    > through <climits>.


    Understood.
    Maxim Yegorushkin, Aug 10, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. j_mckitrick
    Replies:
    2
    Views:
    564
    Cameron Laird
    Nov 13, 2004
  2. NewToCPP
    Replies:
    28
    Views:
    658
    NewToCPP
    Jul 31, 2006
  3. _Who
    Replies:
    7
    Views:
    2,656
  4. namekuseijin

    Re: "Strong typing vs. strong testing"

    namekuseijin, Sep 27, 2010, in forum: C Programming
    Replies:
    214
    Views:
    3,341
    Nick Keighley
    Oct 17, 2010
  5. namekuseijin

    Re: "Strong typing vs. strong testing"

    namekuseijin, Sep 27, 2010, in forum: Python
    Replies:
    229
    Views:
    3,438
    Gregory Ewing
    Oct 29, 2010
Loading...

Share This Page