www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/07/06/05:21:08

Date: Thu, 6 Jul 2000 12:20:12 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Harald Jeszenszky <harald DOT jeszenszky AT oeaw DOT ac DOT at>
cc: djgpp AT delorie DOT com
Subject: Re: Arbitrary variable order ?
In-Reply-To: <396433B4.4370ADC2@oeaw.ac.at>
Message-ID: <Pine.SUN.3.91.1000706121632.24175A-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Thu, 6 Jul 2000, Harald Jeszenszky wrote:

> 	int copy_start;
> 	int variable_1;
> 	...
> 	int variable_n;
> 	int copy_end;
> 	...
> 
> The statement
> 
> 	memcpy(buffer, &copy_start, &copy_end - &copy_start - 1);
> 
> should copy the contents of variable_1 to variable_n to the buffer. This
> works fine on the old platform but fails with DJGPP.
> 
> After comparing the map files it turned out that, on the old platform,
> the varibles are having the same order in memory as they are declared.

That's a heck of an unportable assumption on the part of the program that 
you are porting.  Was that code ported from Fortran or something?

> Is there a way to force the compiler to map the variables in memory in
> the same order as they are declared?

I don't think so.

Why do you need that code, anyway?  Isn't it possible to rewrite it using 
simple variables assignments?  Apart of having to manually write many 
"foo = bar" assignments, this should not present any problems.

- Raw text -


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