Syntax question

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

Syntax question

跳至解决方案
1,013 次查看
GregDavies
Contributor I

I recently downloaded CodeWarrior to start on a project for a MC9S12XDP512. While I was looking through MC9S12XDP512.h, I came across this line (21322):

 

extern volatile DDRSSTR _DDRS @(REG_BASE + 0x0000024AUL);

 

I've never seen the @ character used in this way in C, and I haven't found a search engine that indexes '@', so I can't search for information. Is this a custom addition to CodeWarrior's C or preprocessor syntax?

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
878 次查看
Lundin
Senior Contributor IV

That code isn't valid C, it is written in the Codewarrior language. In C, you would have written:

 

#define DDRS   (*(volatile DDRSSTR*)(REG_BASE + 0x0000024AUL))

 

That's just one of many non-standard things in the register map. They made this non-standard @ solution because they couldn't figure out how to provide debug information of registers otherwise.

 

My advise is to throw the default CW register maps in the garbage bin and write new ones in C.

 

在原帖中查看解决方案

0 项奖励
回复
4 回复数
879 次查看
Lundin
Senior Contributor IV

That code isn't valid C, it is written in the Codewarrior language. In C, you would have written:

 

#define DDRS   (*(volatile DDRSSTR*)(REG_BASE + 0x0000024AUL))

 

That's just one of many non-standard things in the register map. They made this non-standard @ solution because they couldn't figure out how to provide debug information of registers otherwise.

 

My advise is to throw the default CW register maps in the garbage bin and write new ones in C.

 

0 项奖励
回复
878 次查看
GregDavies
Contributor I

Thanks for the reply. I was worried this was the case. I don't suppose Freescale supplies a set of gcc friendly register maps?

0 项奖励
回复
878 次查看
bigmac
Specialist III

Hello,

 

This construct is used to map a variable, in this case a hardware register, to a specific address.  This usage is CW specific, and is extensively used within the device header files.

 

Regards,

Mac

 

 

 

0 项奖励
回复
878 次查看
Jim_P
Contributor III

taking a guess

 

when defining like this - - - - I believe that the @ means the address of the variable is being defined, not the contents of the variable.   Could be wrong

0 项奖励
回复