找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 23652|回復(fù): 9
打印 上一主題 下一主題
收起左側(cè)

51單片機keil編譯錯誤error C141: syntax error near ';', expected 'hdata'

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:956788 發(fā)表于 2021-7-27 14:35 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
編譯錯誤如下:
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


代碼如下:
//獨立按鍵(加消抖)
#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);     //延時10ms
                        if(KEY1==0)    //消除前沿抖動
                        {
                                LED1=0;
                                disnum++;
                                if(disnum==10)
                                disnum=0;
                                while(!KEY1); //按鍵松手檢測
                                delay(10);
                                while(!KEY1); //消除后沿抖動
                    }
                }
                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++);
        }
}



分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

沙發(fā)
ID:951194 發(fā)表于 2021-7-27 16:29 | 只看該作者
i j 定義的類型不對 要么字符 要么數(shù)字  咋字符和數(shù)字一起了
回復(fù)

使用道具 舉報

板凳
ID:161164 發(fā)表于 2021-7-27 16:41 | 只看該作者
不要用#define
#define uint unsigned int;
#define uchar unsigned char;
改用 typedef
typedef unsigned int uint;
typedef unsigned char uchar;
回復(fù)

使用道具 舉報

地板
ID:415064 發(fā)表于 2021-7-27 16:47 | 只看該作者
函數(shù)不寫返回值類型嗎
回復(fù)

使用道具 舉報

5#
ID:155507 發(fā)表于 2021-7-27 16:54 | 只看該作者
你可以用
#define uint unsigned int        //不要添加分號
#define uchar unsigned char   //不要添加分號
改用 typedef
typedef unsigned int uint;       //要添加分號
typedef unsigned char uchar;  //要添加分號
回復(fù)

使用道具 舉報

6#
ID:956553 發(fā)表于 2021-7-27 17:07 | 只看該作者
#define 是宏定義 不用加分號
typedef  是類型重定義 得加分號
回復(fù)

使用道具 舉報

7#
ID:956788 發(fā)表于 2021-7-27 17:09 | 只看該作者
效果也很好 發(fā)表于 2021-7-27 17:07
#define 是宏定義 不用加分號
typedef  是類型重定義 得加分號

懂了 謝謝!
回復(fù)

使用道具 舉報

8#
ID:956788 發(fā)表于 2021-7-27 17:09 | 只看該作者
lkc8210 發(fā)表于 2021-7-27 16:41
不要用#define
#define uint unsigned int;
#define uchar unsigned char;

懂了 謝謝
回復(fù)

使用道具 舉報

9#
ID:956788 發(fā)表于 2021-7-27 17:09 | 只看該作者
angmall 發(fā)表于 2021-7-27 16:54
你可以用
#define uint unsigned int        //不要添加分號
#define uchar unsigned char   //不要添加 ...

懂了 謝謝
回復(fù)

使用道具 舉報

10#
ID:955647 發(fā)表于 2021-7-28 21:01 | 只看該作者
#define uint unsigned int;
#define uchar unsigned char;
這兩行不要加分號
回復(fù)

使用道具 舉報

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

本版積分規(guī)則

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

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

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