keil51报错error C231:‘ TL2‘:redefinition 怎么办 没办法创建HEX文件

#include <reg51.h> #include <intrins.h> // ??HC-SR04?? sbit TR1 = P1^0; sbit ECHO1 = P1^1; sbit TR2 = P1^2; sbit ECHO2 = P1^3; // ??????? sbit main_red = P2^0; sbit main_yellow = P2^1; sbit main_green = P2^2; sbit country_red = P2^3; sbit country_yellow = P2^4; sbit country_green = P2^5; // ?????? void delay(unsigned int t) { while (t--); } // ?????? bit check_car(sbit TR, sbit ECHO) { TR = 1; _nop_();_nop_();_nop_();_nop_();_nop_(); TR = 0; while (ECHO == 0); unsigned int time = 0; while (ECHO == 1) { time++; _nop_(); if (time > 10000) break; } // ????(???????,??????200???) return time < 200; } void main() { while (1) { bit main_car = check_car(TR1, ECHO1); bit country_car = check_car(TR2, ECHO2); if (!country_car) { // ????,??????? main_green = 1; main_red = 0; main_yellow = 0; country_red = 1; country_green = 0; country_yellow = 0; } else { // ???? if (main_car) { // ?????,???? // ????? main_green = 1; main_red = 0; main_yellow = 0; country_red = 1; country_green = 0; country_yellow = 0; delay(5000); // ??????(??) // ??????? main_green = 0; main_yellow = 1; delay(1000); // ??????(??) // ?????,???? main_yellow = 0; main_red = 1; country_red = 0; country_green = 1; delay(3000); // ??????(??) // ?????? country_green = 0; country_yellow = 1; delay(1000); country_yellow = 0; country_red = 1; main_red = 0; main_green = 1; // ?? } else { // ?????,???? country_red = 0; country_green = 1; main_red = 1; main_green = 0; delay(3000); // ?????? country_green = 0; country_yellow = 1; delay(1000); country_yellow = 0; country_red = 1; main_red = 0; main_green = 1; } } } }在我在Keil uVision5中编译C程序,编译为.hex文件时出现问题Build target 'Target 1' compiling main.c... main.c(5): error C231: 'TR1': redefinition main.c(24): error C141: syntax error near 'sbit', expected 'bit' main.c(25): error C202: 'TR': undefined identifier main.c(27): error C202: 'TR': undefined identifier main.c(28): error C202: 'ECHO': undefined identifier main.c(29): error C141: syntax error near 'unsigned', expected '__asm' main.c(29): error C202: 'time': undefined identifier main.c(30): error C202: 'ECHO': undefined identifier main.c(31): error C202: 'time': undefined identifier main.c(33): error C202: 'time': undefined identifier main.c(36): error C202: 'time': undefined identifier Target not created. Build Time Elapsed: 00:00:00
05-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值