为什么用指针会出这种警告?
发布: 2009-10-02 13:50 | 作者: 白日按菜肴 | 来源: StmFans思蜕盟 OPELC 自由电子联盟
程序大概类似这样:
#pragma location=0xOOOO
uc8 F11;
uc16 F12;
uc32 F13;
......
......
uc8 F34;
uc8 Verification;
u8 main(void)
{
...
u8 *p,*q, tmp=0;
for (*p=F11,*q=Verification; p<q; p++)
tmp += *p++;
if (tmp!=Verification)
校验错误处理程序。
可是为什么会出这种警告:
Warning[Pe549]: variable "p" is used before its value is set
怎样才能消除这种警告呢?
#pragma location=0xOOOO
uc8 F11;
uc16 F12;
uc32 F13;
......
......
uc8 F34;
uc8 Verification;
u8 main(void)
{
...
u8 *p,*q, tmp=0;
for (*p=F11,*q=Verification; p<q; p++)
tmp += *p++;
if (tmp!=Verification)
校验错误处理程序。
可是为什么会出这种警告:
Warning[Pe549]: variable "p" is used before its value is set
怎样才能消除这种警告呢?

指针p在没有赋初值,就进行了*p操作,这在C语言编程中绝对要禁止的。
*p=F11 是把F11的值填进P所指的单元,而原来误解为把FF的地址传给P。
p=&F11才是对的。
QUOTE:
学习了,谢谢。本来编译器可以不理你,高高兴兴的执行下去的……^_^