局部函數返回值不一樣引起重定義錯誤

問題描述:

有一outputResultDataFromZbarImage()  函數,定義如下:

void outputResultDataFromZbarImage(char *pOutputWordszbar_image_t *pZbarImg)

{

int                  found    = 0;

const zbar_symbol_t *pSymbol  = NULL;

。。。

}

使用處爲:

int scan_image(zbar_processor_t *pProcessorunsigned charpGrayImgint widthint heightchar *pOutputWords)

{

zbar_image_t        *pZbarImg = NULL;

pZbarImg = createZbarImage();

initZbarImage(pZbarImgpGrayImgwidthheight);

zbar_process_image(pProcessorpZbarImg);

// output result data

outputResultDataFromZbarImage(pOutputWordspZbarImg);

}

編譯後,出現如下錯誤:

warning C4013: “outputResultDataFromZbarImage”未定義;假設外部返回int

error C2371: “outputResultDataFromZbarImage”: 重定義;不同的基類型

 

分析問題:

開始時,覺得內部函數的返回值,和外部函數的返回值沒有多大關係,因爲initZbarImage() 函數也是void返回類型。於是考慮是不是指針出了問題,但修改指針變量始終存在這個問題。

 

解決問題:

    修改函數的返回類型:

    int outputResultDataFromZbarImage(char *pOutputWordszbar_image_t *pZbarImg)

{

int                  found    = 0;

const zbar_symbol_t *pSymbol  = NULL;

    。。。。。。

    通過編譯。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章