找回密码
 注册
搜索
查看: 1149|回复: 0

[讨论] 请教问题

[复制链接]
发表于 2005-11-23 11:44:00 | 显示全部楼层 |阅读模式
原贴地址
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 指向的值?
高级模式
B Color Image Link Quote Code Smilies

本版积分规则

Archiver|手机版|小黑屋|52RD我爱研发网 ( 沪ICP备2022007804号-2 )

GMT+8, 2024-11-23 01:29 , Processed in 0.059438 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表