找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 1672|回復(fù): 4
收起左側(cè)

為什么單片機(jī)程序十八行顯示missing return value怎么修改?

[復(fù)制鏈接]
ID:1058814 發(fā)表于 2022-12-23 08:20 | 顯示全部樓層 |閱讀模式
單片機(jī)源程序如下:
#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;
}

回復(fù)

使用道具 舉報(bào)

ID:161164 發(fā)表于 2022-12-23 09:39 | 顯示全部樓層
十三行delay前加 void
回復(fù)

使用道具 舉報(bào)

ID:77589 發(fā)表于 2022-12-23 09:54 | 顯示全部樓層
沒給函數(shù)明確返回?cái)?shù)據(jù)類型
回復(fù)

使用道具 舉報(bào)

ID:1034262 發(fā)表于 2022-12-23 10:57 | 顯示全部樓層
缺少函數(shù)返回值
回復(fù)

使用道具 舉報(bào)

ID:883242 發(fā)表于 2022-12-23 14:45 | 顯示全部樓層
出現(xiàn)這個(gè)問題的原因樓上都說了,不再贅述。但是這個(gè)warning不會(huì)造成任何問題,事實(shí)上程序員是根本不會(huì)理會(huì)什么warning的。
回復(fù)

使用道具 舉報(bào)

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表