HC12 Need to declare 2 variables at the same address

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HC12 Need to declare 2 variables at the same address

Jump to solution
1,422 Views
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

Labels (1)
Tags (1)
0 Kudos
1 Solution
488 Views
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

View solution in original post

0 Kudos
1 Reply
489 Views
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 Kudos