标题: 函数编译报错error: #167: argument of type "int" is incompatible [打印本页]

作者: 重拾单片机    时间: 2019-9-6 21:34
标题: 函数编译报错error: #167: argument of type "int" is incompatible
函数
  1. // Parameters     : x,y -- 起始点坐标(x:0~127, y:0~7); ch[] -- 要显示的字符串; TextSize -- 字符大小(1:6*8 ; 2:8*16)
  2. // Description    : 显示codetab.h中的ASCII字符,有6*8和8*16可选择
  3. void OLED_ShowStr(unsigned char x, unsigned char y,unsigned char j,unsigned char TextSize)
  4. {
  5.         unsigned char c = 0,i = 0;
  6. //        unsigned char j = 0;
  7.         switch(TextSize)
  8.         {
  9.                 case 1:
  10.                 {
  11.                 while(j != '\0')
  12.                         {                                
  13.                                c = j - 32;
  14.                                 if(x > 126)
  15.                                 {
  16.                                         x = 0;
  17.                                         y++;
  18.                                 }
  19.                                 OLED_SetPos(x,y);
  20.                                 for(i=0;i<6;i++)
  21.                                         WriteDat(F6x8[c][i]);
  22.                                 x += 6;
  23.                                 j++;
  24.                         }
  25.                 }break;
  26.                 case 2:
  27.                 {
  28.                         while(j != '\0')
  29.                         {
  30.                                 c = j - 32;
  31.                                 if(x > 120)
  32.                                 {
  33.                                         x = 0;
  34.                                         y++;
  35.                                 }
  36.                                 OLED_SetPos(x,y);
  37.                                 for(i=0;i<8;i++)
  38.                                         WriteDat(F8X16[c*16+i]);
  39.                                 OLED_SetPos(x,y+1);
  40.                                 for(i=0;i<8;i++)
  41.                                         WriteDat(F8X16[c*16+i+8]);
  42.                                 x += 8;
  43.                                 j++;
  44.                         }
  45.                 }break;
  46.         }
  47. }
复制代码

调用函数
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