C语言指针问题
#include<iom16v.h>#include<macros.h>//字符库定义#pragmadata:codeconstunsignedcharEnglishCo...
#include <iom16v.h>
#include <macros.h>
//字符库定义
#pragma data: code
const unsigned char EnglishCode[]={
0x2e, //字符001
0x2e, //字符002
0x43, //字符003
};
flash unsigned int ChineseCode[]={
0xccab, //字符1
0xd7d3 //字符5
};
const unsigned char EnglishCharDot[]={
0x00,....,/*[_]0x20 */
0x10,.....,/* 1 0x25 */
};
const unsigned char ChineseCharDot[]={
0x10,0x00,......,0xA0,0x40,0x2F,,0x00,/*"保",0*/
0x7E,.......0x40,0x84,0x40,,0x08,/*"闭",1*/
0x10,0x40,...,0x08,0x84,/*"编",2*/
0x08,0x40,....,0x00,/*"裁",3*/
};
#pragma data:data
//-------------------------------------------------------------------------------
void putchar(unsigned int c) //定位写字符子程序
{ if(c>128)
putsizeimage(CHINESECHARSIZE,CHINESECHARSIZE,getchinesecodepos(c));
else
putsizeimage(ENGLISHCHARSIZE,CHINESECHARSIZE,getenglishcodepos(c));
}
//-------------------------------------------------------------------------------
void putstr(unsigned char *s)
{ unsigned int c;
while(1)
{ c=*s;
s++;
if(c==0) break;
if(c<128)
putchar(c);
else
{ putchar(c*256+*s);
s++;
}
}
}
//-------------------------------------------------------------------------------
unsigned char *getchinesecodepos(unsigned int ac)
{ unsigned int min,max,mid,midc;
min=0;
max=CHINESECHARNUMBER-1;
while(1)
{ if(max-min<2)
{ if(ChineseCode[min]==ac)
mid=min;
else if(ChineseCode[max]==ac)
mid=max;
else
mid=0;
break;
}
mid=(max+min)/2;
midc=ChineseCode[mid];
if(midc==ac)
break;
else if(midc>ac)
max=mid-1;
else
min=mid+1;
}
return ChineseCharDot + mid * CHINESECHARDOTSIZE; 这里出问题
}
//-------------------------------------------------------------------------------
unsigned char *getenglishcodepos(unsigned char ac)
{ unsigned char min,max,mid,midc;
min = 0;
max = ENGLISHCHARNUMBER-1;
while(1)
{ if(max-min<2)
{ if(EnglishCode[min]==ac)
mid=min;
else if(EnglishCode[max]==ac)
mid=max;
else
mid=0;
break;
}
mid=(max+min)/2;
midc=EnglishCode[mid];
if(midc==ac)
break;
else if(midc>ac)
max=mid-1;
else
min=mid+1;
}
return EnglishCharDot+mid*ENGLISHCHARDOTSIZE; 这里出问题
}
ERR:illegal return type; found `pointer to const unsigned char' expected `pointer to unsigned char'
把字库放在FLASH里面就出现了 这个怎麼解决啊 搞好好久了 展开
#include <macros.h>
//字符库定义
#pragma data: code
const unsigned char EnglishCode[]={
0x2e, //字符001
0x2e, //字符002
0x43, //字符003
};
flash unsigned int ChineseCode[]={
0xccab, //字符1
0xd7d3 //字符5
};
const unsigned char EnglishCharDot[]={
0x00,....,/*[_]0x20 */
0x10,.....,/* 1 0x25 */
};
const unsigned char ChineseCharDot[]={
0x10,0x00,......,0xA0,0x40,0x2F,,0x00,/*"保",0*/
0x7E,.......0x40,0x84,0x40,,0x08,/*"闭",1*/
0x10,0x40,...,0x08,0x84,/*"编",2*/
0x08,0x40,....,0x00,/*"裁",3*/
};
#pragma data:data
//-------------------------------------------------------------------------------
void putchar(unsigned int c) //定位写字符子程序
{ if(c>128)
putsizeimage(CHINESECHARSIZE,CHINESECHARSIZE,getchinesecodepos(c));
else
putsizeimage(ENGLISHCHARSIZE,CHINESECHARSIZE,getenglishcodepos(c));
}
//-------------------------------------------------------------------------------
void putstr(unsigned char *s)
{ unsigned int c;
while(1)
{ c=*s;
s++;
if(c==0) break;
if(c<128)
putchar(c);
else
{ putchar(c*256+*s);
s++;
}
}
}
//-------------------------------------------------------------------------------
unsigned char *getchinesecodepos(unsigned int ac)
{ unsigned int min,max,mid,midc;
min=0;
max=CHINESECHARNUMBER-1;
while(1)
{ if(max-min<2)
{ if(ChineseCode[min]==ac)
mid=min;
else if(ChineseCode[max]==ac)
mid=max;
else
mid=0;
break;
}
mid=(max+min)/2;
midc=ChineseCode[mid];
if(midc==ac)
break;
else if(midc>ac)
max=mid-1;
else
min=mid+1;
}
return ChineseCharDot + mid * CHINESECHARDOTSIZE; 这里出问题
}
//-------------------------------------------------------------------------------
unsigned char *getenglishcodepos(unsigned char ac)
{ unsigned char min,max,mid,midc;
min = 0;
max = ENGLISHCHARNUMBER-1;
while(1)
{ if(max-min<2)
{ if(EnglishCode[min]==ac)
mid=min;
else if(EnglishCode[max]==ac)
mid=max;
else
mid=0;
break;
}
mid=(max+min)/2;
midc=EnglishCode[mid];
if(midc==ac)
break;
else if(midc>ac)
max=mid-1;
else
min=mid+1;
}
return EnglishCharDot+mid*ENGLISHCHARDOTSIZE; 这里出问题
}
ERR:illegal return type; found `pointer to const unsigned char' expected `pointer to unsigned char'
把字库放在FLASH里面就出现了 这个怎麼解决啊 搞好好久了 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询