using the '@' directive , to assign a variable to specific address

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

using the '@' directive , to assign a variable to specific address

跳至解决方案
1,319 次查看
lel_chen
Contributor I

Hi,

    To assign a variable to a specific addresses, I tried using the '@' directive as given below:

 

int glob @0x0500 = 10;

 

This gives a compiler error which says:

"Expected ; instead of '@' ".

 

I tried with the C99 & GCC extensions enabled in c/C++ Language settings tab. This did not help.

 

Any solutions?

 

Thanks,

Chen

0 项奖励
1 解答
600 次查看
CarlFST60L
Senior Contributor II

This thread really has nothing to do with MQX :smileywink:

 

Firstly, you should define the varible as global i.e. outside your code body in the following format

 

volatile type name @0xADDRESS;         

 

//Example copied from one of my 8 bit processors I happen to have open

volatile unsigned char __far NV_ICSTRM_FAR @0x0000FFBE;

 

 

You could always check the header files for definitions of the standard ports and copy those :smileywink:

 

Message Edited by CarlFST60L on 2009-08-11 11:21 PM

在原帖中查看解决方案

0 项奖励
2 回复数
601 次查看
CarlFST60L
Senior Contributor II

This thread really has nothing to do with MQX :smileywink:

 

Firstly, you should define the varible as global i.e. outside your code body in the following format

 

volatile type name @0xADDRESS;         

 

//Example copied from one of my 8 bit processors I happen to have open

volatile unsigned char __far NV_ICSTRM_FAR @0x0000FFBE;

 

 

You could always check the header files for definitions of the standard ports and copy those :smileywink:

 

Message Edited by CarlFST60L on 2009-08-11 11:21 PM
0 项奖励
600 次查看
lel_chen
Contributor I

Thank You,

        I hadnt declared it as a global - that was the mistake.

 

Thanks,

Chen

0 项奖励