找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 19510|回复: 9
打印 上一主题 下一主题
收起左侧

51单片机keil编译错误error C141: syntax error near ';', expected 'hdata'

[复制链接]
跳转到指定楼层
楼主
ID:956788 发表于 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,                                //数码管段选编码
                          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空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:951194 发表于 2021-7-27 16:29 | 只看该作者
i j 定义的类型不对 要么字符 要么数字  咋字符和数字一起了
回复

使用道具 举报

板凳
ID:161164 发表于 2021-7-27 16:41 | 只看该作者
不要用#define
#define uint unsigned int;
#define uchar unsigned char;
改用 typedef
typedef unsigned int uint;
typedef unsigned char uchar;
回复

使用道具 举报

地板
ID:415064 发表于 2021-7-27 16:47 | 只看该作者
函数不写返回值类型吗
回复

使用道具 举报

5#
ID:155507 发表于 2021-7-27 16:54 | 只看该作者
你可以用
#define uint unsigned int        //不要添加分号
#define uchar unsigned char   //不要添加分号
改用 typedef
typedef unsigned int uint;       //要添加分号
typedef unsigned char uchar;  //要添加分号
回复

使用道具 举报

6#
ID:956553 发表于 2021-7-27 17:07 | 只看该作者
#define 是宏定义 不用加分号
typedef  是类型重定义 得加分号
回复

使用道具 举报

7#
ID:956788 发表于 2021-7-27 17:09 | 只看该作者
效果也很好 发表于 2021-7-27 17:07
#define 是宏定义 不用加分号
typedef  是类型重定义 得加分号

懂了 谢谢!
回复

使用道具 举报

8#
ID:956788 发表于 2021-7-27 17:09 | 只看该作者
lkc8210 发表于 2021-7-27 16:41
不要用#define
#define uint unsigned int;
#define uchar unsigned char;

懂了 谢谢
回复

使用道具 举报

9#
ID:956788 发表于 2021-7-27 17:09 | 只看该作者
angmall 发表于 2021-7-27 16:54
你可以用
#define uint unsigned int        //不要添加分号
#define uchar unsigned char   //不要添加 ...

懂了 谢谢
回复

使用道具 举报

10#
ID:955647 发表于 2021-7-28 21:01 | 只看该作者
#define uint unsigned int;
#define uchar unsigned char;
这两行不要加分号
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表