问题描述:
有一outputResultDataFromZbarImage() 函数,定义如下:
void outputResultDataFromZbarImage(char *pOutputWords, zbar_image_t *pZbarImg)
{
int found = 0;
const zbar_symbol_t *pSymbol = NULL;
。。。
}
使用处为:
int scan_image(zbar_processor_t *pProcessor, unsigned char* pGrayImg, int width, int height, char *pOutputWords)
{
zbar_image_t *pZbarImg = NULL;
pZbarImg = createZbarImage();
initZbarImage(pZbarImg, pGrayImg, width, height);
zbar_process_image(pProcessor, pZbarImg);
// output result data
outputResultDataFromZbarImage(pOutputWords, pZbarImg);
}
编译后,出现如下错误:
warning C4013: “outputResultDataFromZbarImage”未定义;假设外部返回int
error C2371: “outputResultDataFromZbarImage”: 重定义;不同的基类型
分析问题:
开始时,觉得内部函数的返回值,和外部函数的返回值没有多大关系,因为initZbarImage() 函数也是void返回类型。于是考虑是不是指针出了问题,但修改指针变量始终存在这个问题。
解决问题:
修改函数的返回类型:
int outputResultDataFromZbarImage(char *pOutputWords, zbar_image_t *pZbarImg)
{
int found = 0;
const zbar_symbol_t *pSymbol = NULL;
。。。。。。
通过编译。