我在 Dev C++ 中为我的 C++ 项目解析一个 XML 文件,我在 rapidxml_iterators.hpp 文件中有以下代码:
typedef xml_node<Ch> value_type;
typedef xml_node<Ch> &reference;
typedef xml_node<Ch> *pointer;
typedef typename std:: ptrdiff_t difference_type;
typedef typename std:: bidirectional_iterator_tag iterator_category;
它给我这些错误:
no class template named `ptrdiff_t' in `std'
ISO C++ forbids declaration of `difference_type' with no type
no class template named `bidirectional_iterator_tag' in `std'
ISO C++ forbids declaration of `iterator_category' with no type
在出现这些错误之前,上面的代码如下:
typedef typename xml_node<Ch> value_type;
typedef typename xml_node<Ch> &reference;
typedef typename xml_node<Ch> *pointer;
typedef std:: ptrdiff_t difference_type;
typedef std:: bidirectional_iterator_tag iterator_category;
这给了我这样的嵌套名称说明符错误:
expected nested-name-specifier
`xml_node<Ch>' specified as declarator-id
two or more data types in declaration of `xml_node<Ch>'
expected `;' before "value_type"
在我进行解析的主文件中,我包含以下内容:
#include <iostream>
#include "rapidxml.hpp"
#include "rapidxml_iterators.hpp"
#include "rapidxml_print.hpp"
#include "rapidxml_utils.hpp"
#include <iterator>
#include <istream>
#include <cstdlib>
#include <string>
#include <queue>
#include <vector>
#include <streambuf>
#include <cstddef>
我已经在这个网站上四处寻找类似的帖子,并且关注了他们 建议,但到目前为止都没有解决我的问题。 Dev C++ 或我的代码有问题吗?谢谢
最佳答案
在你做任何其他事情之前,尝试删除行:-
#include "rapidxml_iterators.hpp"
它通常不是必需的——没有它你也可以完美地使用 rapidxml,据我所知,它是许多痛苦和奇怪的编译器错误的根源。
关于c++ - 使用 Dev C++ 在 C++ 中使用 RapidXML 编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15255697/