错误 C267: 'LcdAreaClear': requires ANSI-style prototype 请教如何改错
时间:10-02
整理:3721RD
点击:
求高手指教,如何改,谢谢!
程序:
/******************main.c文件程序源代码*************************/
#include<reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char
unsigned char step = 0; //操作步骤
unsigned char oprt = 0; //运算类型
signed long num1 = 0; //操作数1
signed long num2 = 0; //操作数2
signed long result = 0; //运算结果
unsigned char TORH = 0; //TO重载值的高字节
unsigned char TORL = 0; //TO重载值的低字节
void ConfigTimer0 ( unsigned int ms);
extern void KeyScan();
extern void KeyDriver();
extern void InitLcd1602();
extern void LcdShowStr( unsigned char x, unsigned char y, unsigned char * str);
extern void LcdAreaClear( unsigned char x, unsigned char y,unsigned char len );
extern void LcdFullClear();
void main()
{
EA = 1; //开总中断
ConfigTimer0(1); //配置TO定时1ms
InitLcd1602(); //初始化液晶
LcdShowStr(15,1,"0"); //初始显示一个数字0
while(1)
{
KeyDriver(); //调用按键驱动
}
}
/*长整型数转换为字符串,str为字符串指针,dat为待转换数,返回值为字符串长度*/
unsigned char LongToString(unsigned char * str,signed long dat)
{
signed char i = 0;
unsigned char len = 0;
unsigned char buf[12];
if(dat < 0) //如果为负数,首先取绝对值,并在指针上添加负号
{
dat = -dat;
* str++ = '-';
len++;
}
do{ //先转换为低位在前的十进制数组
buf[i++] = dat % 10;
dat/=10;
}while(dat > 0);
len += i; //i最后的值就是有效字符的个数
while(i-- > 0 ) //将数组值转换为ASCII码反向拷贝到接收指针上
{
* str++ = buf[i] + '0';
}
* str = '\0'; //添加字符串结束符
return len; //返回字符串长符
}
/*显示运算符,显示位置y,运算符类型type*/
void ShowOprt(unsigned char y, unsigned char type)
{
switch(type)
{
case 0: LcdShowStr(0,y,"+");break; //0代表+
case 1: LcdShowStr(0,y,"-");break; //1代表-
case 2: LcdShowStr(0,y,"*");break; //2代表*
case 3: LcdShowStr(0,y,"/");break; //3代表/
default: break;
}
}
/*计算器复位,清零变量值,清除屏幕显示*/
void Reset()
{
num1 = 0;
num2 = 0;
step = 0;
LcdFullClear();
}
/*数字键动作函数,n为按键输入的数值*/
void NumKeyAction(unsigned char n)
{
unsigned char len;
unsigned char str[12];
if(step >1)
{
Reset();
}
if(step == 0)
{
num1 = num1 * 10 + n;
len = LongToString(str,num1);
LcdShowStr(16-len,1,str);
}
else
{
num2 = num2 * 10 + n;
len = LongToString(str,num2);
LcdShowStr(16-len,1,str);
}
}
/*运算符按键动作函数,运算符类型type*/
void OprtKeyAction(unsigned char type)
{
unsigned char len;
unsigned char str[12];
if(step == 0) //第二操作数尚未输入时响应,即不支持连续操作
{
len = LongToString(str,num1); //第一操作数转换为字符串
LcdAreaClear(0, 0, 16-len); //清除第一行左边的字符位(这句错了)
LcdShowStr(16 - len, 0, str); //字符串靠右显示在第一行
ShowOprt(1,type); //在第二行显示操作符
LcdAreaClear(1,1,14); //清除第二行中间的字符位
LcdShowStr(15,1,"0"); //在第二行最右端显示0
oprt = type; //记录操作类型
step = 1;
}
}
程序:
/******************main.c文件程序源代码*************************/
#include<reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char
unsigned char step = 0; //操作步骤
unsigned char oprt = 0; //运算类型
signed long num1 = 0; //操作数1
signed long num2 = 0; //操作数2
signed long result = 0; //运算结果
unsigned char TORH = 0; //TO重载值的高字节
unsigned char TORL = 0; //TO重载值的低字节
void ConfigTimer0 ( unsigned int ms);
extern void KeyScan();
extern void KeyDriver();
extern void InitLcd1602();
extern void LcdShowStr( unsigned char x, unsigned char y, unsigned char * str);
extern void LcdAreaClear( unsigned char x, unsigned char y,unsigned char len );
extern void LcdFullClear();
void main()
{
EA = 1; //开总中断
ConfigTimer0(1); //配置TO定时1ms
InitLcd1602(); //初始化液晶
LcdShowStr(15,1,"0"); //初始显示一个数字0
while(1)
{
KeyDriver(); //调用按键驱动
}
}
/*长整型数转换为字符串,str为字符串指针,dat为待转换数,返回值为字符串长度*/
unsigned char LongToString(unsigned char * str,signed long dat)
{
signed char i = 0;
unsigned char len = 0;
unsigned char buf[12];
if(dat < 0) //如果为负数,首先取绝对值,并在指针上添加负号
{
dat = -dat;
* str++ = '-';
len++;
}
do{ //先转换为低位在前的十进制数组
buf[i++] = dat % 10;
dat/=10;
}while(dat > 0);
len += i; //i最后的值就是有效字符的个数
while(i-- > 0 ) //将数组值转换为ASCII码反向拷贝到接收指针上
{
* str++ = buf[i] + '0';
}
* str = '\0'; //添加字符串结束符
return len; //返回字符串长符
}
/*显示运算符,显示位置y,运算符类型type*/
void ShowOprt(unsigned char y, unsigned char type)
{
switch(type)
{
case 0: LcdShowStr(0,y,"+");break; //0代表+
case 1: LcdShowStr(0,y,"-");break; //1代表-
case 2: LcdShowStr(0,y,"*");break; //2代表*
case 3: LcdShowStr(0,y,"/");break; //3代表/
default: break;
}
}
/*计算器复位,清零变量值,清除屏幕显示*/
void Reset()
{
num1 = 0;
num2 = 0;
step = 0;
LcdFullClear();
}
/*数字键动作函数,n为按键输入的数值*/
void NumKeyAction(unsigned char n)
{
unsigned char len;
unsigned char str[12];
if(step >1)
{
Reset();
}
if(step == 0)
{
num1 = num1 * 10 + n;
len = LongToString(str,num1);
LcdShowStr(16-len,1,str);
}
else
{
num2 = num2 * 10 + n;
len = LongToString(str,num2);
LcdShowStr(16-len,1,str);
}
}
/*运算符按键动作函数,运算符类型type*/
void OprtKeyAction(unsigned char type)
{
unsigned char len;
unsigned char str[12];
if(step == 0) //第二操作数尚未输入时响应,即不支持连续操作
{
len = LongToString(str,num1); //第一操作数转换为字符串
LcdAreaClear(0, 0, 16-len); //清除第一行左边的字符位(这句错了)
LcdShowStr(16 - len, 0, str); //字符串靠右显示在第一行
ShowOprt(1,type); //在第二行显示操作符
LcdAreaClear(1,1,14); //清除第二行中间的字符位
LcdShowStr(15,1,"0"); //在第二行最右端显示0
oprt = type; //记录操作类型
step = 1;
}
}
这个错我找到了,是重复定义“LcdAreaClear”的函数,“extern void LcdAreaClear( unsigned char x, unsigned char y,unsigned char len );”改为:“extern void LcdArcaClear( unsigned char x, unsigned char y,unsigned char len );” ,都改为 “LcdArcaClear”就可以了。