找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 1740|回復(fù): 3
打印 上一主題 下一主題
收起左側(cè)

編譯錯(cuò)誤error C267: 'write_data': requires ANSI-style prototype附程序

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:976415 發(fā)表于 2022-3-3 23:50 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
1.c(20): error C267: 'write_data': requires ANSI-style prototype
#include <AT89X51.h>bit dsinit();
void write_data();
unsigned char readdata();
sbit ds=P3^3;
unsigned int i;
unsigned int t1;
unsigned char t2;
unsigned char t;
int j;
unsigned char dat,rdata;
bit b;


void main()
{
while(1)
{
dsinit();
write_data(0xCC);
write_data(0x44);
dsinit();
write_data(0xCC);
write_data(0xbe);
t1=readdata();
t2=readdata();
t2=(t2<<8)|t1;

}


}

bit dsinit()
{
ds=0;
i=60;
while(i>0)i--;
ds=1;
i=4;
while(i>0)i--;
while(!ds);
i=60;
while(i>0)i--;
}

void write_data()
{
for(j=0;j>0;j--)
{
b=dat&0x01;
dat>>=1;
if(b)
{
ds=0;
i=2;
while(i>0)i--;
ds=1;
i=7;
while(i>0)i--;
}
else
{
ds=0;
i=8;
while(i>0)i--;
ds=1;
i++;i++;
}
}}


unsigned char readdata()
{

for(j=8;j>0;j--)
{
rdata>>=1;
ds=0;
i++;
ds=1;
i++;i++;
if(ds)
rdata=rdata|0x80;
i=8;
while(i>0)i--;
ds=1;
}
return rdata;
}
分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:86926 發(fā)表于 2022-3-4 08:19 | 只看該作者
函數(shù)沒有寫形參類型,調(diào)用時(shí)又給了參數(shù)
回復(fù)

使用道具 舉報(bào)

板凳
ID:995903 發(fā)表于 2022-3-4 20:36 | 只看該作者
在main函數(shù)前面加一句
void write_data();
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表