我今天遇到了这个问题,只是想知道如何检查是否在某处定义了一个用typedef定义的新类型.举个例子,我开始使用我从源代码构建的Xerces-c3库并编写了一个xml2text转换器.但我无法在fbsd上找到Xerces-c3端口,因此安装了Xerces-c2库.
当我尝试重新编译我的源代码时,我收到以下错误:
XML2Text.cc:83: error: cannot declare variable 'handler' to be of abstract type 'XML2TextHandlers'
XML2TextHandlers.h:32: note: because the following virtual functions are pure within 'XML2TextHandlers':
/usr/local/include/xercesc/framework/XMLFormatter.hpp:454: note: virtual void xercesc_2_7::XMLFormatTarget::writeChars(const XMLByte*, unsigned int, xercesc_2_7::XMLFormatter*)
Run Code Online (Sandbox Code Playgroud)
我在头文件中使用了以下定义来获取writeChars方法
virtual void writeChars(const XMLByte* const toWrite,
const XMLSize_t count,
XMLFormatter* const formatter );
Run Code Online (Sandbox Code Playgroud)
我检查过XMLSize_t只是通过以下方式声明的unsigned int:
#define XERCES_SIZE_T size_t
typedef XERCES_SIZE_T XMLSize_t;
Run Code Online (Sandbox Code Playgroud)
因此,如果我想使代码兼容两个库,我将如何做?我能想到的一种方法是检查库的版本是否相应定义XMLSize_t.还有其他方法吗?
谢谢,
Shripad