delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/18/11:17:02

From: "Jasper van Woudenberg" <p DOT v DOT woudenberg AT consunet DOT nl>
Newsgroups: comp.os.msdos.djgpp
Subject: Struct optimizing by compiler
Date: 18 Apr 1998 14:45:37 GMT
Organization: World Online
Lines: 16
Message-ID: <01bd6ad8$16320920$151601bf@cb001687>
NNTP-Posting-Host: asd2-p48.worldonline.nl
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi,

When i try to define a structure, it seems that the compiler sometimes
optimizes the variables to start at a 'long' address. for example:

struct X { short X,            // (can) reserve 4 bytes for X, to get Y at
a 'long' address
           long  Y,
           short Z };

Sometimes interrupt routines return pointers to data structures in memory,
and when i copy that data into a structure like the above, the data is
corrupted, because X uses 4 bytes in stead of 2 bytes. How can i make the
compiler _always_ reserve 2 bytes for a short, 4 bytes for a long, etc.?

Jasper.

- Raw text -


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