2013-10-18 14 views
1

我問了這個問題here。但問題似乎是別的東西,所以重新張貼在這裏..頭文件包含在main.cpp中,但是在類中拋出錯誤

我包括0123.從Zbar library main.cpp和示例代碼工作得很好。

#include <iostream> 
#include <Magick++.h> 
#include <zbar.h> 
#include <highgui.h> 
#include <cv.h> 

using namespace std; 
using namespace zbar; 
using namespace cv; 

int main (int argc, char **argv){ 
if(argc < 2) return(1); 

// create a reader 
ImageScanner scanner; 

// configure the reader 
scanner.set_config(ZBAR_NONE, ZBAR_CFG_ENABLE, 1); 

// obtain image data 
Magick::Image magick(argv[1]); // read an image file 
int width = magick.columns(); // extract dimensions 
int height = magick.rows(); 
Magick::Blob blob;    // extract the raw data 
magick.modifyImage(); 
magick.write(&blob, "GRAY", 8); 
const void *raw = blob.data(); 

// wrap image data 
Image image(width, height, "Y800", raw, width * height); 

// scan the image for barcodes 
int n = scanner.scan(image); 

cv::Mat dispImage = imread(argv[1]); 

// extract results 
for(Image::SymbolIterator symbol = image.symbol_begin(); 
    symbol != image.symbol_end(); 
    ++symbol) { 
    // do something useful with results 
    cout << "decoded " << symbol->get_type_name() 
     << " symbol \"" << symbol->get_data() << '"' << endl; 
     } 
} 
// clean up 
image.set_data(NULL, 0); 

return(0); 
} 

但是,如果我做一個虛擬類,幷包括在這個類的頭zbar.h,我得到以下錯誤:

the default argument for parameter 0 of ‘zbar::Exception::Exception(const void*)’ has not yet been parsed line 144, external location: /usr/local/include/zbar/Exception.h C/C++ Problem

#ifndef DUMMY_H 
#define DUMMY_H 

#include <zbar.h> 

class dummy{ 
public: 
    dummy(); 
}; 

#endif // DUMMY_H 

我即使

嘗試
extern "C"{ 
    #include <zbar.h> 
} 

但它拋出template with C linkage錯誤的100s。

+0

有沒有zbar.cpp – harsh

回答

2

this documentation,構造函數聲明爲

Exception(const void * = NULL); 

錯誤表明NULL尚未聲明;這意味着什麼都沒有包括<cstddef>。你應該可以通過在邪惡頭部之前包含你自己來修復它。

+0

其實我也認爲這是一個錯誤..'/usr/local/include/zbar/Exception.h:43:錯誤:'NULL'未在此範圍內聲明。將嘗試一下。謝謝! – harsh

+0

我試過了包括,, ......但問題依然存在! – harsh

+0

但是爲什麼它在main.cpp中有效,但在dummy.h中不起作用?如果NULL是未定義的,它甚至不應該在main.cpp中工作,對吧? – harsh

相關問題