freeman05 发表于 2007-6-1 08:43

CCS关于volatile问题

当运行一下语句时;<br />unsigned&nbsp;int&nbsp;*iFlashAddr;<br />iFlashAddr=(volatile&nbsp;unsigned&nbsp;int*)0xffff;<br /><br />出现这样的错误提示:<br />&quot;flash.c&quot;,&nbsp;line&nbsp;49:&nbsp;error:&nbsp;a&nbsp;value&nbsp;of&nbsp;type&nbsp;&quot;volatile&nbsp;unsigned&nbsp;int&nbsp;*&quot;&nbsp;cannot&nbsp;be&nbsp;assigned&nbsp;to&nbsp;an&nbsp;entity&nbsp;of&nbsp;type&nbsp;&quot;unsigned&nbsp;int&nbsp;*&quot;<br /><br />请问这是为什么啊?

cehon 发表于 2007-6-1 10:24

如下

类型不匹配吧

acecao 发表于 2007-6-2 09:51

rr

该这样吧<br />iFlashAddr=*(volatile&nbsp;unsigned&nbsp;int*)0xffff

freeman05 发表于 2007-6-2 10:43

这样

这样<br />iFlashAddr=*(volatile&nbsp;unsigned&nbsp;int*)0xffff<br /><br />就会这样了:<br />&quot;flash.c&quot;,&nbsp;line&nbsp;19:&nbsp;error:&nbsp;a&nbsp;value&nbsp;of&nbsp;type&nbsp;&quot;unsigned&nbsp;int&quot;&nbsp;cannot&nbsp;be&nbsp;assigned&nbsp;to&nbsp;an&nbsp;entity&nbsp;of&nbsp;type&nbsp;&quot;unsigned&nbsp;int&nbsp;*&quot;<br />

acecao 发表于 2007-6-2 19:21

感觉这两句代码要实现的功能是将I/O空间或数据空间FFFFh地址的内容当作FLASH程序的首地址。<br />unsigned&nbsp;int&nbsp;iFlashAddr;&nbsp;<br />iFlashAddr=*(volatile&nbsp;unsigned&nbsp;int*)0xffff;<br /><br />or:<br /><br />unsigned&nbsp;int&nbsp;*iFlashAddr;<br />*(iFlashAddr)=*(volatile&nbsp;unsigned&nbsp;int*)0xffff;<br /><br /><br />

zhr123456 发表于 2013-8-23 11:55

定义 int iFlashAddr;
iFlashAddr=*(volatile int *)0xffff;

zhangmangui 发表于 2013-8-23 13:42

受教了

aresc 发表于 2013-8-24 16:39

应该是:
volatile unsigned int *iFlashAddr;

iFlashAddr = (volatile unsigned int *)0xffff;

hczsea 发表于 2013-8-26 10:16

那就改成
volatile unsigned int *iFlashAddr;
iFlashAddr=(volatile unsigned int*)0xffff;

lelee007 发表于 2013-8-26 23:33

8L正解,其他都是扯淡
页: [1]
查看完整版本: CCS关于volatile问题