Hi. There are some way to keep all variables declares in my program in the same order in the memory ?
I want to be able to copy blocks of memory with pointers.
But I need that the variables keep in the Ram in the same order that I them declare in the program
Example:
char a;
char b;
char c;
I need the correlative address
address size type variable
1FFF0000 00000001 .dat a
1FFF0001 00000001 .dat b
1FFF0002 00000001 .dat c
I'm workign with CW 10.2, kinetis k60 MCU.
Recently I have changed to kinetis. Before it was working with keil with 8051 MCU. In the uvision ther are the paremetrer " - order " in the compiler, but in CW I don't know.
Thanks !!
Solved! Go to Solution.
Hi,
At least in the C/C++ programming language, you cannot rely on the order of variables, as the linker might change it (e.g. if a variable is not used/etc).
If you rely on the order, then I suggest you put the variables inside a struct.
The other way is that you place the objects into sections and do the placement in the linker, but this might be a lot of work if you do it that way. So I would put them into a struct.
Hi,
At least in the C/C++ programming language, you cannot rely on the order of variables, as the linker might change it (e.g. if a variable is not used/etc).
If you rely on the order, then I suggest you put the variables inside a struct.
The other way is that you place the objects into sections and do the placement in the linker, but this might be a lot of work if you do it that way. So I would put them into a struct.
Hi Erich,
I will change everything to structures. I need to have them in order to copy in blocks to external memories, etc..
It's a work, but less than put all in sections.
Thanks !!