Re: 4 byte length storage

Ruben Safir <ruben-v1XHP5QhJixWk0Htik3J/[email protected]>
Newsgroups gmane.comp.graphics.png.devel
Message-ID <[email protected]>
On Tue, Dec 06, 2016 at 07:04:46PM +0100, Andreas Kleinert wrote:
> In theory (and future, or past) much might (have) be(en) possible. Probably it is a science on its own to become 100% rocksolid under any possible potential circumstances, and to test & prove that.  However such specific env. conditions just might easily break other more sophisticated code parts of the same library elsewhere. Thus if sizeof(uint32_t) does not equal 4 I would consider this a good reason to stop compiling ;-)
> 
> Von meinem iPhone gesendet


I suppose that is what autoconf is for.  I don't otherwise know how to
say, give me a single variable worth 4 bytes or 8 bits


> 
> > Am 06.12.2016 um 18:32 schrieb John Bowler <[email protected]>:
> > 
> > On Tue, Dec 6, 2016 at 8:55 AM, Andreas Kleinert
> > <[email protected]> wrote:
> >> I have not really checked your code in detail, but are you sure it is not just big vs. little endian conversion...?!
> > 
> > That's why '13' (0x0000000D) appears as 218103808 (0x0D000000), but
> > there are other issues in the code that are perhaps best covered by an
> > online tutorial such as this one:
> > 
> > https://isocpp.org/wiki/faq/serialization
> > 
> > (That's C++ specific).
> > 
> > One issue is that the code relies on uint32_t being a four byte
> > quantity, CHUNK is a typedef of uint32_t:
> > 
> >                char * cur = get_index();
> >                CHUNK * tmp = reinterpret_cast<CHUNK *>(cur);
> > 
> > Certainly uint32_t is required to have exactly 32 bits and therefore
> > behave as a 32-bit value for modular arithmetic (per the ANSI C spec),
> > however I don't know that the representation is constrained to be 4
> > bytes.  I would be surprised if C89 (which formalized the type) had
> > done that and so far as I can see the above code has undefined
> > behavior.
> > 
> > The general rule for serialization is to either use well-defined
> > primitives or to do it yourself; the code is not exactly difficult to
> > write, though it can be difficult to get right sometimes ;-)
> > 
> > John Bowler
> > 
> > ------------------------------------------------------------------------------
> > Developer Access Program for Intel Xeon Phi Processors
> > Access to Intel Xeon Phi processor-based developer platforms.
> > With one year of Intel Parallel Studio XE.
> > Training and support from Colfax.
> > Order your platform today.http://sdm.link/xeonphi
> > _______________________________________________
> > png-mng-implement mailing list
> > png-mng-implement-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> > https://lists.sourceforge.net/lists/listinfo/png-mng-implement
> 
> 
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today.http://sdm.link/xeonphi
> _______________________________________________
> png-mng-implement mailing list
> png-mng-implement-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/png-mng-implement

-- 
So many immigrant groups have swept through our town
that Brooklyn, like Atlantis, reaches mythological
proportions in the mind of the world - RI Safir 1998
http://www.mrbrklyn.com 

DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002
http://www.nylxs.com - Leadership Development in Free Software
http://www2.mrbrklyn.com/resources - Unpublished Archive 
http://www.coinhangout.com - coins!
http://www.brooklyn-living.com 

Being so tracked is for FARM ANIMALS and and extermination camps, 
but incompatible with living as a free human being. -RI Safir 2013


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.