找回密码
 立即注册

QQ登录

只需一步,快速开始

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

单片机数码管程序编译错误

[复制链接]
跳转到指定楼层
楼主
ID:737696 发表于 2020-4-25 14:09 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
啥情况 我对着师傅的一摸一样  就是错 把数组去掉就没问题了
#include<reg52.h>
typedef unsigned char u8;
typedef unsigned int u16;
sbit seg_sel=P1^5;
sbit bit_sel=P1^4;
#define DATA P0
u8 seg_tab[]={0xc0,0xf9,0xa4,0xb0,
                                0x99,0x92,0x82,0xf8,
                                0x80,0x90}
                                void main(void){
                                                        P0=0Xff;
                                                        P1=0xff;
                                                        seg_sel=0;
                                                        bit_sel=0;
                                                        while(1){
                                                        bit_sel=1;
                                                        DATA=0x80;
                                                        bit_sel=0;
                                                        seg_sel=1;
                                                        DATA=seg_tab[1];
                                                        seg_sel=0;
                                                        }
                                }


错误

Build target '目标 1'
compiling 数码管3.c...
事牍?.c(10): error C141: syntax error near 'void'
事牍?.c(10): error C141: syntax error near '{'
事牍?.c(11): error C231: 'P0': redefinition
事牍?.c(11): error C231: 'P0': redefinition
事牍?.c(12): error C231: 'P1': redefinition
事牍?.c(12): error C231: 'P1': redefinition
事牍?.c(13): error C231: 'seg_sel': redefinition
事牍?.c(13): error C231: 'seg_sel': redefinition
事牍?.c(14): error C231: 'bit_sel': redefinition
事牍?.c(14): error C231: 'bit_sel': redefinition
事牍?.c(15): error C141: syntax error near 'while'
事牍?.c(15): error C141: syntax error near '1'
事牍?.c(16): error C279: 'bit_sel': multiple initialization
事牍?.c(16): error C231: 'bit_sel': redefinition
事牍?.c(16): error C231: 'bit_sel': redefinition
事牍?.c(17): error C279: 'P0': multiple initialization
事牍?.c(17): error C231: 'P0': redefinition
事牍?.c(17): error C231: 'P0': redefinition
事牍?.c(18): error C279: 'bit_sel': multiple initialization
事牍?.c(18): error C231: 'bit_sel': redefinition
事牍?.c(18): error C231: 'bit_sel': redefinition
事牍?.c(19): error C279: 'seg_sel': multiple initialization
事牍?.c(19): error C231: 'seg_sel': redefinition
事牍?.c(19): error C231: 'seg_sel': redefinition
事牍?.c(20): error C279: 'P0': multiple initialization
事牍?.c(20): error C231: 'P0': redefinition
事牍?.c(20): error C231: 'P0': redefinition
事牍?.c(21): error C279: 'seg_sel': multiple initialization
事牍?.c(21): error C231: 'seg_sel': redefinition
事牍?.c(21): error C231: 'seg_sel': redefinition
事牍?.c(22): error C141: syntax error near '}'
目标未创建

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:213173 发表于 2020-4-25 17:00 | 只看该作者
你与师傅的差别就是数组后面少一个 ; 。
回复

使用道具 举报

板凳
ID:70069 发表于 2020-4-25 19:47 | 只看该作者
数组后面少了个分号
回复

使用道具 举报

地板
ID:695749 发表于 2020-4-25 20:46 | 只看该作者
u8 seg_tab[]={0xc0,0xf9,0xa4,0xb0, 0x99,0x92,0x82,0xf8, 0x80,0x90} ;//
回复

使用道具 举报

5#
ID:600952 发表于 2020-4-25 23:53 | 只看该作者
就是数组后面得加个分号,想这样:
u8 seg_tab[]={0xc0,0xf9,0xa4,0xb0,                                0x99,0x92,0x82,0xf8,                                0x80,0x90} ;
我有时也很粗心,这种错误编译器有时还找不准地方,还是应该熟练些,第一次就写对,出错再找太麻烦。感谢你,给我也提个醒。
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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