Keep variables in order. CW 10.2, Kinetis K60

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Keep variables in order. CW 10.2, Kinetis K60

ソリューションへジャンプ
1,145件の閲覧回数
carlosburgos
Contributor I

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 !!

ラベル(1)
タグ(3)
0 件の賞賛
返信
1 解決策
1,056件の閲覧回数
BlackNight
NXP Employee
NXP Employee

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.

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
1,057件の閲覧回数
BlackNight
NXP Employee
NXP Employee

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.

0 件の賞賛
返信
1,056件の閲覧回数
carlosburgos
Contributor I

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  !!

0 件の賞賛
返信