www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/07/06/03:36:47

From: Harald Jeszenszky <harald DOT jeszenszky AT oeaw DOT ac DOT at>
Newsgroups: comp.os.msdos.djgpp
Subject: Arbitrary variable order ?
Date: Thu, 06 Jul 2000 09:22:28 +0200
Organization: Technische Universitaet Graz, Austria
Lines: 34
Message-ID: <396433B4.4370ADC2@oeaw.ac.at>
NNTP-Posting-Host: fiwfpc111.tu-graz.ac.at
Mime-Version: 1.0
X-Trace: fstgss02.tu-graz.ac.at 962868144 10436 129.27.195.111 (6 Jul 2000 07:22:24 GMT)
X-Complaints-To: news AT zid DOT tu-graz DOT ac DOT at
NNTP-Posting-Date: 6 Jul 2000 07:22:24 GMT
X-Mailer: Mozilla 4.72 [de] (WinNT; U)
X-Accept-Language: de
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hello,

I've ported a large program to DJGPP and I can compile and run it
without any problems. The program uses two variables (lets say
copy_start, and copy_end) for copying some data from memory to a buffer.
The variables are declared as follows:

	...
	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.
In the DJGPP version the variables are stored in arbitrary order in 
memory !!! The address of the variable copy_end was less than the
address of the variable copy_start !!!

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

Thanks in advance

Harald (harald DOT jeszenszky AT oeaw DOT ac DOT at)

- Raw text -


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