From -6137596375456509496
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,290ced9644daa112
X-Google-Attributes: gidf78e5,public
From: Brian White <bcwhite@verisim.com>
Subject: Re: Types with Bit-Sizes
Date: 1998/03/17
Message-ID: <350DA497.2B484CB4@verisim.com>#1/1
X-Deja-AN: 334712816
Content-Transfer-Encoding: 7bit
References: <35084BDC.4108978E@verisim.com> <paul-1303981134270001@206.169.118.19>
X-Original-Date: Mon, 16 Mar 1998 17:15:51 -0500
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: usenet@news20.bellglobal.com
X-Trace: news21.bellglobal.com 890086833 3595 (None) 207.236.110.153
Organization: Verisim, Inc.  http://www.verisim.com/
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUANQ2/YOEDnX0m9pzZAQFdJwF9FwumfD4PnqQopMobvBuDVFs74POkJdyn ikxaJsb9YSZkFTjepTfmCvseSc6nbPBb =7nYs
Mime-Version: 1.0
Newsgroups: comp.std.c++


> > Is there anything in the the ANSI C++ spec that provides for datatypes of
> > known bit sizes?
> 
> This get's mentioned quite often around C++, but the reality is that
> passing structs between machines is a really bad idea.
> 
> The best way to achieve compatibility is to override your objects with
> serialize methods (or use streams) to put and get the data.

Unfortunately, this doesn't help unless you convert everything down to
the byte level.  Writing out a sequence of ints will still break if
both machines don't have the same sizeof(int).  If I have to do everything
at the byte-level, what's the point of having any other types in the
first place?


> Relying on bit/byte size, or even the fact that structures will actually
> stay the same size, with members in the same positions between revs of
> compilers/code bases is not realistic.

And therein lies another problem.  Structures get written out to disk or
passed over a network so often that it would be very useful to have some
way of mapping these two in a way that is guaranteed not to change.

                                          Brian
                                 ( bcwhite@verisim.com )

-------------------------------------------------------------------------------
        Stress:  The condition caused by resisiting the desire to choke
            the life out of some idiot who desperately deserves it.
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]



