標(biāo)題: 51單片機(jī)keil編譯錯(cuò)誤error C141: syntax error near ';', expected 'hdata' [打印本頁]

作者: Flynnkk    時(shí)間: 2021-7-27 14:35
標(biāo)題: 51單片機(jī)keil編譯錯(cuò)誤error C141: syntax error near ';', expected 'hdata'
編譯錯(cuò)誤如下:
template.c(173): error C141: syntax error near ';', expected 'hdata'
template.c(206): error C141: syntax error near ';', expected 'hdata'
template.c(208): error C202: 'i': undefined identifier
template.c(209): error C202: 'i': undefined identifier
template.c(211): error C202: 'j': undefined identifier


代碼如下:
//獨(dú)立按鍵(加消抖)
#include<reg52.h>
#define uint unsigned int;
#define uchar unsigned char;
sbit LED1=P1^0;
sbit KEY1=P3^4;
sbit dula=P2^6;
sbit wela=P2^7;
uchar disnum;
uchar code table_du[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,                                //數(shù)碼管段選編碼
                          0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
delay(uchar);
void main()
{
        KEY1=1;
        P0=0xfe;
        wela=1;
        wela=0;
        while(1)
        {
                if(KEY1==0)
                {
                        delay(10);     //延時(shí)10ms
                        if(KEY1==0)    //消除前沿抖動(dòng)
                        {
                                LED1=0;
                                disnum++;
                                if(disnum==10)
                                disnum=0;
                                while(!KEY1); //按鍵松手檢測(cè)
                                delay(10);
                                while(!KEY1); //消除后沿抖動(dòng)
                    }
                }
                else
                {
                        LED1=1;
                        P0=table_du[disnum];
                        dula=1;
                        dula=0;
                }
        }
}

delay(uchar x)
{
        uchar i,j;
        for(i=0;i<x;i++)
        {
                for(j=0;j<200;j++);
        }
}




作者: kern..    時(shí)間: 2021-7-27 16:29
i j 定義的類型不對(duì) 要么字符 要么數(shù)字  咋字符和數(shù)字一起了
作者: lkc8210    時(shí)間: 2021-7-27 16:41
不要用#define
#define uint unsigned int;
#define uchar unsigned char;
改用 typedef
typedef unsigned int uint;
typedef unsigned char uchar;
作者: wojiaoguogai    時(shí)間: 2021-7-27 16:47
函數(shù)不寫返回值類型嗎
作者: angmall    時(shí)間: 2021-7-27 16:54
你可以用
#define uint unsigned int        //不要添加分號(hào)
#define uchar unsigned char   //不要添加分號(hào)
改用 typedef
typedef unsigned int uint;       //要添加分號(hào)
typedef unsigned char uchar;  //要添加分號(hào)

作者: 效果也很好    時(shí)間: 2021-7-27 17:07
#define 是宏定義 不用加分號(hào)
typedef  是類型重定義 得加分號(hào)
作者: Flynnkk    時(shí)間: 2021-7-27 17:09
效果也很好 發(fā)表于 2021-7-27 17:07
#define 是宏定義 不用加分號(hào)
typedef  是類型重定義 得加分號(hào)

懂了 謝謝!
作者: Flynnkk    時(shí)間: 2021-7-27 17:09
lkc8210 發(fā)表于 2021-7-27 16:41
不要用#define
#define uint unsigned int;
#define uchar unsigned char;

懂了 謝謝
作者: Flynnkk    時(shí)間: 2021-7-27 17:09
angmall 發(fā)表于 2021-7-27 16:54
你可以用
#define uint unsigned int        //不要添加分號(hào)
#define uchar unsigned char   //不要添加 ...

懂了 謝謝
作者: 云雀在天    時(shí)間: 2021-7-28 21:01
#define uint unsigned int;
#define uchar unsigned char;
這兩行不要加分號(hào)




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1