delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/18/13:59:44

Date: Sat, 18 Apr 1998 10:55:50 -0700 (PDT)
From: Nate Eldredge <nate AT cartsys DOT com>
To: Jasper van Woudenberg <p DOT v DOT woudenberg AT consunet DOT nl>
cc: djgpp AT delorie DOT com
Subject: Re: Struct optimizing by compiler
In-Reply-To: <01bd6ad8$16320920$151601bf@cb001687>
Message-ID: <Pine.LNX.3.96.980418105346.259D-100000@unixbox.bitbucket.org>
MIME-Version: 1.0

On 18 Apr 1998, Jasper van Woudenberg wrote:

> 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.?

See FAQ sections 22.9 and 22.10.

Nate Eldredge
nate AT cartsys DOT com

- Raw text -


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