delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/30/12:32:32

From: "Christopher Nelson" <paradox AT gye DOT satnet DOT net>
To: <djgpp AT delorie DOT com>
Subject: Re: Some nice questions!! (one of them is silly!)
Date: Tue, 29 Jun 1999 18:19:58 -0600
Message-ID: <01bec28e$4971ec60$LocalHost@thendren>
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 4.71.1712.3
X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3
Reply-To: djgpp AT delorie DOT com


>> >   1) if i declare 2 global arrays as follows...
>> >       char ar1[100];
>> >       char ar2[20];
>> >    will djgpp ALWAYS store ar2 exactly after ar1???
>> >   i.e. will the expression ar2[-1] always return
>> >ar1[99]??
>>
>> you should never assume that two variables are in proximate memory
>> locations.  the compiler and link-editor are under no requirement to put
>> them next to each other.  this is what USUALLY happens, but it's not safe
to
>> assume that it will ALWAYS happen.
>>
>
>he may declare those arrays in some struct with __atribute__(packed)...


yes, but then they wouldn't be two variables.  they would be two members of
the same struct, and therefore underneath a different allocation definition.

    -={C}=-


- Raw text -


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