标题:
函数编译报错error: #167: argument of type "int" is incompatible
[打印本页]
作者:
重拾单片机
时间:
2019-9-6 21:34
标题:
函数编译报错error: #167: argument of type "int" is incompatible
函数
// Parameters : x,y -- 起始点坐标(x:0~127, y:0~7); ch[] -- 要显示的字符串; TextSize -- 字符大小(1:6*8 ; 2:8*16)
// Description : 显示codetab.h中的ASCII字符,有6*8和8*16可选择
void OLED_ShowStr(unsigned char x, unsigned char y,unsigned char j,unsigned char TextSize)
{
unsigned char c = 0,i = 0;
// unsigned char j = 0;
switch(TextSize)
{
case 1:
{
while(j != '\0')
{
c = j - 32;
if(x > 126)
{
x = 0;
y++;
}
OLED_SetPos(x,y);
for(i=0;i<6;i++)
WriteDat(F6x8[c][i]);
x += 6;
j++;
}
}break;
case 2:
{
while(j != '\0')
{
c = j - 32;
if(x > 120)
{
x = 0;
y++;
}
OLED_SetPos(x,y);
for(i=0;i<8;i++)
WriteDat(F8X16[c*16+i]);
OLED_SetPos(x,y+1);
for(i=0;i<8;i++)
WriteDat(F8X16[c*16+i+8]);
x += 8;
j++;
}
}break;
}
}
复制代码
调用函数
OLED_ShowStr(2,1,1,1);
编译错误信息
error: #167: argument of type "int" is incompatible with parameter of type "unsigned char *"
新手实在弄不明白。
作者:
devcang
时间:
2019-9-7 00:35
哪一行是167行。。。。。。。。。仔细检查变量类型、数据类型
函数定义,应该是发送一个字符串的,,,,,传进去整数的参数,类型不对了。
作者:
aaaaabangw
时间:
2019-9-7 13:28
你函数原型有问题吧,这应该是个显示字符串函数,你的形参貌似少了字符串指针??你只传坐标、大小。。。应该是某一个参数应该传字符串指针,你直接传整数肯定是不对的。。。你最好对照函数原型来传参数
作者:
qaz10126
时间:
2019-9-7 14:41
程序的第167行,函数调用传的参数与函数的形参数据类型不匹配, 一个是"int" 一个是 "unsigned char *"
改成与形参一样的类型。
作者:
重拾单片机
时间:
2019-9-9 15:16
devcang 发表于 2019-9-7 00:35
哪一行是167行。。。。。。。。。仔细检查变量类型、数据类型
函数定义,应该是发送一个字符串的,, ...
谢谢!是我自己在调用函数的时候少了个双引号!
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1