标题: 为什么单片机程序十八行显示missing return value怎么修改? [打印本页]

作者: 29209    时间: 2022-12-23 08:20
标题: 为什么单片机程序十八行显示missing return value怎么修改?
单片机源程序如下:
#include<reg51.h>
unsigned char table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned int k,t,m,n;
unsigned int dat_count,dat_count1,w;

sbit led=P1^4;
sbit speaker=P1^5;
sbit js=P1^0;   
sbit z=P1^1;      
sbit j=P1^2;      
sbit q=P1^3;      

delay(unsigned char time)
{
  unsigned char i,j;
   for(i=0;i<time;i++)
    for(j=0;j<120;j++);
}
void INT0_init(void)
{
  IT0=1;
   EA=1;
  EX0=1;
}
void INT1_init(void)
{
   IT1=1;
   EA=1;
   EX1=1;
}
void display()
{
   unsigned int m, shi, ge;
   shi=dat_count/10;
   ge=dat_count%10;
   for(m=100;m>0;m--)
    {
      P0=table[shi];
      P2=0x02;
      delay(1);
      P2=0xff;
                        
      P0=table[ge];
      P2=0x01;
      delay(1);
      P2=0xff;
    }
}

void display1()
{
         unsigned int m1,shi1,ge1;
         if(z==0) dat_count1=dat_count1+1;
         if(j==0) dat_count1=dat_count1-1;
         if(q==0) dat_count1=0;
   shi1=dat_count1/10;
   ge1=dat_count1%10;
   for(m1=200;m1>0;m1--)
    {
      P0=table[shi1];
      P2=0x02;
      delay(2);
      P2=0xff;
                        
      P0=table[ge1];
      P2=0x01;
      delay(2);
      P2=0xff;
    }
}

main()
{
  INT0_init();
  INT1_init();
        dat_count1=0;
  while(1)
{
         if(js==0)
         {
                 display1();
         }
         else
         {
   if(dat_count>=dat_count1)
   {
    led=0;
    speaker=0;
    }
  else
   {
    led=1;
    speaker=1;
   }
   display();
         }
}

}
void Init0() interrupt 0 using 0
{
    EX0=0;
    dat_count++;
    EX0=1;
}
void Init1() interrupt 2 using 1
{
   EX1=0;
   dat_count--;
   EX1=1;
}


作者: lkc8210    时间: 2022-12-23 09:39
十三行delay前加 void
作者: Longan.Wang    时间: 2022-12-23 09:54
没给函数明确返回数据类型
作者: coody_sz    时间: 2022-12-23 10:57
缺少函数返回值
作者: Hephaestus    时间: 2022-12-23 14:45
出现这个问题的原因楼上都说了,不再赘述。但是这个warning不会造成任何问题,事实上程序员是根本不会理会什么warning的。




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1