Syntax question

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
1,070件の閲覧回数
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 解決策
935件の閲覧回数
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 返答(返信)
936件の閲覧回数
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 件の賞賛
返信
935件の閲覧回数
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 件の賞賛
返信
935件の閲覧回数
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 件の賞賛
返信
935件の閲覧回数
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 件の賞賛
返信