找回密码
 立即注册

QQ登录

只需一步,快速开始

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

error C267: 'Recstring': requires ANSI-style prototype新手,求助

[复制链接]
跳转到指定楼层
楼主
ID:82976 发表于 2015-6-14 17:19 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
错误  Build target 'Target 1'compiling Text1.c...
TEXT1.C(56): warning C206: 'Recstring': missing function-prototype
TEXT1.C(56): error C267: 'Recstring': requires ANSI-style prototype
TEXT1.C(56): error C202: 'IIC_Password': undefined identifier
TEXT1.C(57): error C202: 'IIC_Password': undefined identifier
TEXT1.C(62): error C202: 'KeyNo': undefined identifier
TEXT1.C(64): error C202: 'KeyNo': undefined identifier
TEXT1.C(73): error C202: 'UserPassword': undefined identifier
TEXT1.C(74): error C202: 'UserPassword': undefined identifier
TEXT1.C(82): error C202: 'UserPassword': undefined identifier
Target not created



程序:#include<reg51.h>
#include<string.h>
#include<intrins.h>
#define uchar  unsigned char
#define uint  unsigned int
#define delay4us();
uchar Pre_keyNo = 16,keyNo = 16;
uchar code Title_Text[] = "Your password";
uchar DSY_BUFFER[10] =" ";
uchar Userpassword[10] =" ";

void LCD_Init();
void Display_String(uchar * str,ucharLineNo);
void IIC_24C04_Init();
void Beep();
uchar RecString(uchar Slave,uchar Subaddr,uchar *Buffer,uchar N);
uchar SendString(uchar Slave,uchar Subaddr,uchar *Buffer,uchar N);
uchar Keys_Scan();
sbit LED_OPEN =P2^7;
sbit BEEP =P3^7;
void DelayMS(uint x)
{
        uchar i;
        while (x--) for (i = 0; i< 120;i++);
}
void Beep()
{
        uchar i;
        for (i = 0;i<100;i++)
    {
                DelayMS(1);BEEP= ~BEEP;
        }
        BEEP=0;
}
void main()
{
        uchar i = 0;
        uchar IIC_password[10];
        uchar IS_Valid_User = 0;
        P0 = 0xFF;
        P1 = 0xFF;
        P2 = 0xFF;

        TMOD = 0x02;
        TH0 = 175;
        TL0 = 175;
        TR0 = 1;

        DelayMS(10);
        LCD_Init();

        IIC_24C04_Init();

        Display_String(Title_Text,0x00);

        Recstring(0xa0,  0, IIC_Password, 6);
        IIC_Password[6] ='\0';

        while (1)
        {
                P1 = 0xF0;
                if(P1 !=0xf0) KeyNo = Keys_Scan();

                switch (KeyNo)
                {
                    case 0:  case 1:  case 2:  case 3:  case 4:
                        case 5:  case 6:  case 7:  case 8:  case 9:       

                                if (i<= 5)
                                {
                                        if(i ==0) Display_String("           ",0x40);

                                        UserPassword[i] =KeyNo + '0';
                                        UserPassword[i+1] = '\0';
                                        Display_String(DSY_BUFFER,0x40);

                                        i++;
                                }
                                break;

                        case 10:
                                    if(strcmp(UserPassword,IIC_Password) ==0)
                                        {
                                                LED_OPEN = 0;
                                                Clear_Password();
                                                Display_String("Unlock OK!    ",0x40);
                                                IS_Valid_User = 1;
                                        }
                                        else
                                        {
                                                LED_OPEN = 1;
                                                Clear_Password();
                                                Display_String("ERROR!      ",0x40););
                        IS_Valid_User = 0;
                                        }
                                        i = 0;
                                        break;
                        case 11:
                                    LED_OPEN = 1;
                                        Clear_Password();
                                        Display_String(Title_Text,0x00);
                                        Display_String("              ",0x40);
                                        i = 0;
                                        IS_Valid_User = 0;
                                        break;
            case 12:
                                    if(!IS_Valid_User )Display_String("No rights !",0x40);
                                        else
                                        {
                                                i = 0;
                                                Display_String("new password :    ",0x00);
                                                Display_String("            ",0x40);
                                        }

                                        break;
            case 13:
                                    if(!IS_Valid_User ) Display_String("No rights !",0x40);
                                        else
                                        {
                                                SendString(0xa0, 0, UserPassword,6);

                                                RecString(0xa0, 0, IIC_Password,  6);
                                                IIC_password[6] = '\0';

                                                i=0;
                                                Display_String(Title_Text,0x00);
                                                Display_String("Password saved!",0x40);
                                        }
                                        break;
            case 14:
                                    i = 0;
                                        Clear_Password();
                                        Display_String("         ",0x40);
                }
                Beep();
                DelayMS(100);
                P1= 0xF0;
                while (P1  != 0xF0);
                while (P1  == 0xF00;
        }
}
void Start()
{
        SDA = 1;
        SCL = 1;
        Delay4us();
        SDA = 0;
        Delay4us();
        SCL = 0;
}

void ACK()
{
        SDA = 0;
    SCL = 1;
        Delay4us();
        SCL = 0;
        SDA =1;
}
void NO_ACK()
{
        SDA = 1;
         SCL =1;
          Delay4us();
          SCL = 0;
          SDA = 0;
}
uchar RecByte()
{
        Uchar i,rd;
        rd = 0x00;
        SDA = 1;
        for(i = 0;i<8;i++)
        {
                SCL = 1; rd<<=1; rd |=SDA;
                 Delay4us();SCL = 0; Delay4us();
        }
        SCL = 0;
        Delay4us();
        return rd;
}
uchar SendByte(uchar wd)
{
        uchar i;
        bit ack0;
        for(i = 0; i < 8; i++)
        {
                SDA = (bit) (wd & 0x80);
                _nop_();_nop_(); SCL = 1; Delay4us();
                SCL = 0 ; wd<<= 1;
        }
        Delay4us();
        SDA = 1;
        SCL = 1;
        Delay4us();
        ack0 = !SDA;
        SCL = 0;
        Delay4us();
        return ack0;
}
uchar SendString(uchar Slave, uchar Subaddr, uchar *Buffer,uchar N)
{
        uchar i;
        start();
        if (!SendByte(slave))   return 0;
        if (!SendByte(Subaddr))   return 0;
        Start();
        if (!SendByte(Slave + 1)) return 0;
        for(i= 0; i<N-1; i++)
        {
                Buffer[i] = RecByte();
                ACK();
        }
        Buffer[N-1] =RecByte();
        NO_ACK();
        Stop();
        return 1;
}
void DelayMS(unit x);
uchar Keys_scan()
{
        uchar tmp, KeyNo = 0;
        P1 = 0x0F;
        DelayMS(1);
        Tmp = P1 >>4^0x0F;
        switch (Tmp)
        {
            case 1:KeyNo +=0; break;
                case 2:KeyNo +=4; break;
            case 4:KeyNo +=8; break;
                case 8:KeyNo +=12;
        }
        return KeyNo;
}


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

使用道具 举报

沙发
ID:1 发表于 2015-6-23 01:14 | 只看该作者
error C267: 'Recstring': requires ANSI-style prototype 是说函数没有定义  你看看是不是缺少头文件?
回复

使用道具 举报

板凳
ID:83877 发表于 2015-6-25 11:09 | 只看该作者
缺少函数定义

评分

参与人数 1黑币 +50 收起 理由
admin + 50 回帖助人的奖励!

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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