简体   繁体   English

标头包含在main.cpp中,但在类中引发错误

[英]header include in main.cpp works, but throws error in class

I had asked this question here . 我在这里问过这个问题。 But the problem seems to be something else so re-posting here.. 但是问题似乎是另外一回事,所以在这里重新发布。

I am including the header <zbar.h> from Zbar library in main.cpp and the sample code works perfectly fine. 我将main.cpp中Zbar库的标头<zbar.h>包括在内,示例代码工作得很好。

#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);
}

But if I make a dummy class and include zbar.h in the header of this class, I get the following error : 但是,如果我创建了一个虚拟类并将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

I even tried with 我什至尝试

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

but it throws 100s of template with C linkage error. 但它会引发100个template with C linkage错误的template with C linkage

According to this documentation , the constructor is declared as 根据此文档 ,构造函数声明为

Exception(const void * = NULL);

The error suggests that NULL hasn't been declared; 该错误表明尚未声明NULL meaning that nothing has included <cstddef> . 意味着<cstddef>不包含任何<cstddef> You should be able to fix it by including that yourself, before the evil header. 您应该能够通过在邪恶的标头之前包含您自己来解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM