|
原贴地址
http://www.52rd.com/bbs/dispbbs.asp?boardID=38&ID=2048&page=1
一个指针数组定义,在编译ccs上编译有问题,但是在vc上有没有问题,请教!
我写了一个小程序
/*三段内存地址*/
#define SDRAM1 0x80000000
#define SDRAM2 0x83400000
#define SDRAM3 0x86600000
/*定义三个分别指向单元首地址的指针
unsigned volatile int *ptr_SDRAM1 = (unsigned volatile int *)SDRAM1;
unsigned volatile int *ptr_SDRAM2 = (unsigned volatile int *)SDRAM2;
unsigned volatile int *ptr_SDRAM3 = (unsigned volatile int *)SDRAM3;
/*定义一个指针数组*/
unsigned volatile int *ptr_SDRAM[3] = {ptr_SDRAM1, ptr_SDRAM2,
ptr_SDRAM3};
void main()
{}
我在ccs上编译,总是提示指针数组定义那一行出错,error: expression must
have a constant value。我就不明白了?
然后我把指针数组定义成这样,又提示没有错了:
unsigned volatile int *ptr_SDRAM[3] = {(unsigned volatile int *)
SDRAM1, (unsigned volatile int *)SDRAM2, (unsigned volatile int *)
SDRAM3};
最后我又做了一次修改,结果又提示出错:
unsigned volatile int *ptr_SDRAM[3];
ptr_SDRAM[1]=(unsigned volatile int *)SDRAM2;
大家帮我解惑啊?:)
unsigned volatile int *ptr_SDRAM1 =(* (unsigned volatile int *)SDRAM1);
unsigned volatile int *ptr_SDRAM2 = (*(unsigned volatile int *)SDRAM2);
unsigned volatile int *ptr_SDRAM3 = (*(unsigned volatile int *)SDRAM3);
楼下xd的方案不明白阿,指针 等于 SDRAM1 指向的值? |
|