HC12 Need to declare 2 variables at the same address

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

HC12 Need to declare 2 variables at the same address

ソリューションへジャンプ
1,641件の閲覧回数
hdan
Contributor III
Hello,

I work with code warrior hc12 3.1 build 4047

I need to declare 2 variables at the same address
(really need that not an access with pointer )

the first variable:
extern unsigned int _AL;
...
unsigned int _AL = 0;

i try this:

unsigned int BD @ &_AL;
but it doesn't compile => the message "illegal use of global address modifier"

someone have the correct definition ?

Thanks,

Message Edited by CrasyCat on 2007-04-13 10:59 AM

ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
707件の閲覧回数
CompilerGuru
NXP Employee
NXP Employee
The usual way in C to do this is to use a union.

If _AL and _BL both are int's I wonder why you need two separate variables? If the reason for the second variable is another type,
then using a cast may do the trick
#define _BL (*(signed int)&_AL)

As third thing to look at is the PAGED qualifier in the prm file.
different not initialized variables can be placed into different PAGED segments, that's actually the only purpose of the PAGED qualifier.

Daniel

元の投稿で解決策を見る

0 件の賞賛
返信
1 返信
708件の閲覧回数
CompilerGuru
NXP Employee
NXP Employee
The usual way in C to do this is to use a union.

If _AL and _BL both are int's I wonder why you need two separate variables? If the reason for the second variable is another type,
then using a cast may do the trick
#define _BL (*(signed int)&_AL)

As third thing to look at is the PAGED qualifier in the prm file.
different not initialized variables can be placed into different PAGED segments, that's actually the only purpose of the PAGED qualifier.

Daniel
0 件の賞賛
返信