C++ header include在main.cpp中起作用,但在类中抛出错误
我问过这个问题。但是问题似乎是其他的,所以请在这里重新发布 我在main.cpp中包含了标题C++ header include在main.cpp中起作用,但在类中抛出错误,c++,c,C++,C,我问过这个问题。但是问题似乎是其他的,所以请在这里重新发布 我在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;
,示例代码运行得非常好
#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);
}
我甚至试过用它
extern "C"{
#include <zbar.h>
}
extern“C”{
#包括
}
但是它抛出100个带有C链接的模板
错误。根据,构造函数被声明为
Exception(const void * = NULL);
错误表明未声明
NULL
;意思是没有包含任何内容
。您应该能够通过在邪恶标题之前包含它来修复它。事实上,我也认为这是一个错误<代码>/usr/local/include/zbar/Exception.h:43:错误:此范围中未声明“NULL”。我会试试看。谢谢我试着包括。。。但问题依然存在!但为什么它在main.cpp中工作而在dummy.h中不工作呢?如果NULL是未定义的,那么即使在main.cpp中它也不应该工作,对吗?对不起。。。成功了!!!整晚都睡不着。。。但问题仍然存在<代码>为什么它在main.cpp中工作而在dummy.h中不工作?如果NULL未定义,那么它即使在main.cpp中也不应该工作,对吗?@harsh:您的示例程序包括几个其他头文件;其中一个必须包括
(直接或间接)。
Exception(const void * = NULL);