This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Order of the variables in the memory



Hi,

Is there any Mechanism for the order of variables in the memory?

eg:

/*four global variable*/

int Vara;
int Varb;
int Varc;
int Vard;

how can I get a map file looks like:

0000cc40   Vara
0000cc41   Varb
0000cc42   Varc
0000cc43   Vard


it seems that, even I use the #pragma to put them in one mem section "section1", I can't design the order "VaraVarbVarcVard" in the memory.
#pragma DATA_SECTION(Vara,"section1");
#pragma DATA_SECTION(Varb,"section1");
#pragma DATA_SECTION(Varc,"section1");
#pragma DATA_SECTION(Vard,"section1");

so i use

#pragma DATA_SECTION(Vara,"section1");
#pragma DATA_SECTION(Varb,"section2");
#pragma DATA_SECTION(Varc,"section3");
#pragma DATA_SECTION(Vard,"section4");

and the sections one by one, then I can determin the order.

Is there any simple method to achieve this order?

Thanks