This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
global variables not defined contiguously in memory
- From: mikwilmot <michael dot i dot wilmot dot ctr at navy dot mil>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 5 Mar 2009 07:07:35 -0800 (PST)
- Subject: global variables not defined contiguously in memory
We are having a problem with defining global variables and having them
allocated contiguously in memory. There are two portions of two different
files. In FILE 1 the variables are defined all over memory, in FILE 2 the
variables are defined contiguously in memory. Our application has certain
reads that requires variables be defined one after another in memory.
*****
VxWorks 6.5 and VxWorks Edition 3.5 Platforms
Wind River GNU Compiler 3.4.4 for VxWorks 6.5
*****
FILE 1
...
/*--- GLOBAL DATA ---*/
INT32 calibrationStart = 0;
int gbbt1;
long int gbbt2;
float gbbt3;
double gbbt4;
char gbbt5;
int gbbt6;
#include "craft_control_iface_cal.h"
#include "hull_cal.h"
INT32 calibrationChecksum = ERROR;
INT32 calibrationEnd = 0;
#undef LOCATE_CALS
...
******
FILE 2
...
int globalI1 = 1;
float globalF1 = 1.0;
char globalC1 = '1';
teststub()
{
int i2;
float f2;
char c2;
i2 = 2;
f2 = 2.0;
c2 = '2';
printf("Address of globalI1 = %x contents = %x\n",&globalI1, globalI1);
printf("Address of globalF1 = %x contents = %x\n",&globalF1, globalF1);
printf("Address of globalC1 = %x contents = %x\n",&globalC1, globalC1);
printf("Address of i2 = %x contents = %x\n",&i2, i2);
printf("Address of f2 = %x contents = %x\n",&f2,f2);
printf("Address of c2 = %x contents = %x\n",&c2,c2);
}
...
*****
RESULTS OF teststub.
-> teststub
Address of globalI1 = 319d8d8 contents = 1
Address of globalF1 = 319d8dc contents = 1
Address of globalC1 = 319d8e0 contents = 31
Address of i2 = 23c4cf8 contents = 2
Address of f2 = 23c4cfc contents = 1
Address of c2 = 23c4d00 contents = 32
value = 49414056 = 0x2f1ffa8 = teststub + 0x13c
****
Variables from FILE 1 that are not in order in memory:
-> calibrationStart
calibrationStart = 0x32080d4: value = 0 = 0x0
-> gbbt1
gbbt1 = 0x32c1da0: value = 0 = 0x0
-> printf ("%x",&gbbt1)
32c1da0value = 7 = 0x7
-> gbbt2
gbbt2 = 0x32e8710: value = 0 = 0x0
-> gbbt3
gbbt3 = 0x3219c43: value = 0 = 0x0
--
View this message in context: http://www.nabble.com/global-variables-not-defined-contiguously-in-memory-tp22353471p22353471.html
Sent from the gcc - Help mailing list archive at Nabble.com.