www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/15/12:11:00

From: nick AT tcp DOT co DOT uk (Nick Austin)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: General protection fault because of modulus?
Date: Tue, 15 Jul 1997 05:28:08 GMT
Organization: 0%
Lines: 35
Message-ID: <5qf1pr$elp$2@zeus.tcp.net.uk>
References: <1 DOT 5 DOT 4 DOT 32 DOT 19970714201438 DOT 006b5c88 AT dce03 DOT ipt DOT br>
NNTP-Posting-Host: du-050.tcp.co.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Cesar Scarpini Rabak <csrabak AT dce03 DOT ipt DOT br> wrote:

>At 17:48 09/07/97 -0400, A. Sinan Unur wrote:
>>levity AT minn DOT net wrote:
>>> 
>>> I am writing a program for the purpous of learing how to read binary 
>>> files.
>>
>>in general, it is not a good idea to read/write whole structures at
>>once.

>Why not? The host OS would not buffer data anyway?

Structures are good for holding data in volatile memory, where
they disappear when the programme quits.  Write structures to
disk and you could end up opening a whole can of worms.

The mapping of elements to memory addresses within a structure is
a compile-time decision.  For example a compiler may add padder
bytes to a structure to make the compiled code execute faster.

Therfore, if you recompile the programme using a different
compiler (or the same compiler with different options) the
internal memory layout of the structure will be different
and the programme won't be able to read any of the data it
previously wrote.

Additionally, the code may be difficult to port.  Including
a format such as 'float' is unlikely to work on another
processor, the underlying machine architecture may have alignment
restrictions copying anything larger than a byte into
registers, and the byte-ordering of integers may be different.

Nick.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019