Keil的c语言程序有很多错误,求大神指点!!急求,谢谢!!
#include<reg51.h>#include<stdio.h>#include<stdlib.h>unsignedcharfood;unsignedcharerro...
#include <reg51.h>
#include <stdio.h>
#include <stdlib.h>
unsigned char food;
unsigned char error;
unsigned char time;
void timer_init()
{
ET0=1; //¿ª¶¨Ê±Æ÷0ÖжÏ
TMOD=0x02; //¶¨Ê±Æ÷0¹¤×÷ÔÚ·½Ê½2
TL0=6; //¶¨Ê±250us
TH0=6;
EA=1; //´ò¿ª×ÜÖжÏ
TR0=1; //¿ªÊ¼¶¨Ê±
}
/*Ö÷º¯Êý*/
void main()
{
IT0 = 1; //ÍⲿÖжÏ0·½Ê½£¬Ï½µÑØ
EA = 1; //¿ªÆô×ÜÖжÏ
EX0 = 1; //¿ªÆôÍⲿÖжÏ
while(1)
{
gamestart();
}
snack_pr.c(45): error C132: 'food': not in formal parameter list
snack_pr.c(46): error C132: 'error': not in formal parameter list
snack_pr.c(47): error C132: 'time': not in formal parameter list
snack_pr.c(57): error C132: 'timer_init': not in formal parameter list
snack_pr.c(57): error C141: syntax error near '{'
snack_pr.c(58): error C136: 'ET0': 'void' on variable
snack_pr.c(58): error C244: 'ET0': can't initialize, bad type or class
snack_pr.c(58): error C136: 'ET0': 'void' on variable
snack_pr.c(58): error C132: 'ET0': not in formal parameter list
snack_pr.c(59): error C244: 'TMOD': can't initialize, bad type or class
snack_pr.c(59): error C132: 'TMOD': not in formal parameter list
snack_pr.c(60): error C244: 'TL0': can't initialize, bad type or class
snack_pr.c(60): error C132: 'TL0': not in formal parameter list
snack_pr.c(61): error C244: 'TH0': can't initialize, bad type or class
snack_pr.c(61): error C132: 'TH0': not in formal parameter list
snack_pr.c(62): error C244: 'EA': can't initialize, bad type or class
snack_pr.c(62): error C132: 'EA': not in formal parameter list
snack_pr.c(63): error C244: 'TR0': can't initialize, bad type or class
snack_pr.c(63): error C132: 'TR0': not in formal parameter list
snack_pr.c(64): error C141: syntax error near '}'
snack_pr.c(111): error C141: syntax error near 'void'
snack_pr.c(112): error C141: syntax error near '{'
snack_pr.c(130): error C202: 'food': undefined identifier
snack_pr.c(135): error C141: syntax error near 'void'
snack_pr.c(136): error C141: syntax error near '{'
snack_pr.c(159): error C141: syntax error near 'void' 展开
#include <stdio.h>
#include <stdlib.h>
unsigned char food;
unsigned char error;
unsigned char time;
void timer_init()
{
ET0=1; //¿ª¶¨Ê±Æ÷0ÖжÏ
TMOD=0x02; //¶¨Ê±Æ÷0¹¤×÷ÔÚ·½Ê½2
TL0=6; //¶¨Ê±250us
TH0=6;
EA=1; //´ò¿ª×ÜÖжÏ
TR0=1; //¿ªÊ¼¶¨Ê±
}
/*Ö÷º¯Êý*/
void main()
{
IT0 = 1; //ÍⲿÖжÏ0·½Ê½£¬Ï½µÑØ
EA = 1; //¿ªÆô×ÜÖжÏ
EX0 = 1; //¿ªÆôÍⲿÖжÏ
while(1)
{
gamestart();
}
snack_pr.c(45): error C132: 'food': not in formal parameter list
snack_pr.c(46): error C132: 'error': not in formal parameter list
snack_pr.c(47): error C132: 'time': not in formal parameter list
snack_pr.c(57): error C132: 'timer_init': not in formal parameter list
snack_pr.c(57): error C141: syntax error near '{'
snack_pr.c(58): error C136: 'ET0': 'void' on variable
snack_pr.c(58): error C244: 'ET0': can't initialize, bad type or class
snack_pr.c(58): error C136: 'ET0': 'void' on variable
snack_pr.c(58): error C132: 'ET0': not in formal parameter list
snack_pr.c(59): error C244: 'TMOD': can't initialize, bad type or class
snack_pr.c(59): error C132: 'TMOD': not in formal parameter list
snack_pr.c(60): error C244: 'TL0': can't initialize, bad type or class
snack_pr.c(60): error C132: 'TL0': not in formal parameter list
snack_pr.c(61): error C244: 'TH0': can't initialize, bad type or class
snack_pr.c(61): error C132: 'TH0': not in formal parameter list
snack_pr.c(62): error C244: 'EA': can't initialize, bad type or class
snack_pr.c(62): error C132: 'EA': not in formal parameter list
snack_pr.c(63): error C244: 'TR0': can't initialize, bad type or class
snack_pr.c(63): error C132: 'TR0': not in formal parameter list
snack_pr.c(64): error C141: syntax error near '}'
snack_pr.c(111): error C141: syntax error near 'void'
snack_pr.c(112): error C141: syntax error near '{'
snack_pr.c(130): error C202: 'food': undefined identifier
snack_pr.c(135): error C141: syntax error near 'void'
snack_pr.c(136): error C141: syntax error near '{'
snack_pr.c(159): error C141: syntax error near 'void' 展开
展开全部
你这主要不是程序问题,估计是没有破解吧。
程序没有这么多问题,那变量是正常的。还有那些寄存器都是正常的。
只是这个子函数 gamestart(); 没有实际的函数,只是警告。
程序没有这么多问题,那变量是正常的。还有那些寄存器都是正常的。
只是这个子函数 gamestart(); 没有实际的函数,只是警告。
追问
谢谢,我刚刚调试了好久 warning C280: 'error': unreferenced local variable/ warning C280: 'x': unreferenced local variable/warning C291: not every exit path returns a valu/WARNING L1: UNRESOLVED EXTERNAL SYMBOL/SYMBOL: MOVEMENT/MODULE: .\Objects\snack_pr.obj (SNACK_PR/WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNA/SYMBOL: MOVEMENT/MODULE: .\Objects\snack_pr.obj (SNACK_PR)/ADDRESS: 03FD
追答
只是两个警告:一是gamestart(),这个函数没有实体函数,二是timer_init() ,这个函数没有被调用,要主程序中 调用一次。
其它没有错误,还是你的keil 有问题,或者是版本问题,安装的是ARM版本的吧?
是这些信息,但是可以生成代码的
BAIDUA.C(29): warning C206: 'gamestart': missing function-prototype
linking...
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?TIMER_INIT?BAIDUA//timer_init() ,这个函数没有被调用
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
SYMBOL: GAMESTART
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: GAMESTART//gamestart(),这个函数没有实体函数
MODULE: baidua.obj (BAIDUA)
ADDRESS: 0026H
Program Size: data=12.0 xdata=0 code=42
0 Error(s), 4 Warning(s).
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |