#define register

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

#define register

跳至解决方案
6,029 次查看
elee40
Contributor I
I am using a freescale hc12 with codewarrior and trying to use a #define to refer to a memory register but continue to receive an error.  The error I get is
C2450: Expected ~ (IDENT auto const extern register static typedef volatile__interrupt friend inline operator virtual) .  I realize that these definitions are already in the header files....But for educational purposes I am trying to define my own references to the memory registers. Any help or suggestions would be much appreciated.
 
#include <hidef.h>      /* common defines and macros */
#include <mc9s12dt256.h>     /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dt256b"
#define EPCNT 0x000000AC
EPCNT = 0; 
 
  Thanks
        Erik
标签 (1)
标记 (1)
0 项奖励
回复
1 解答
2,197 次查看
joeservo
Contributor III
try something like this:
 
#define PORTA    (*((volatile unsigned char*) (0x0000)))
 
what you are doing is only defining the number to a word.
 
you will probably get a link error about duplicate register names.  i usually change that to a warning and ignore.

在原帖中查看解决方案

0 项奖励
回复
3 回复数
2,198 次查看
joeservo
Contributor III
try something like this:
 
#define PORTA    (*((volatile unsigned char*) (0x0000)))
 
what you are doing is only defining the number to a word.
 
you will probably get a link error about duplicate register names.  i usually change that to a warning and ignore.
0 项奖励
回复
2,197 次查看
elee40
Contributor I
Still getting error C2450: Expected: ~ (IDENT operator .  Also getting error C1067: Object is missing decl specifiers.  I looked at the help under these errors, but as I am not the greatest programmer the explanation was not clear. 
 
#include <hidef.h>      /* common defines and macros */
#include <mc9s12dt256.h>     /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dt256b"
#define EPWM (*((volatile unsigned char*) (0x000000AC)))
EPWM = 0;
 
Erik
0 项奖励
回复
2,197 次查看
elee40
Contributor I
Ignore my previous message.  It works as long as I assign a value to the memory register inside of main().  Thanks again.  Erik
0 项奖励
回复