简体   繁体   中英

Parsing an XML file in C++ using RapidXML with Dev C++

So I have to parse an XML file for my C++ project in class and I'm using RapidXML. The rapidxml_iterators.hpp file is giving me some troubles. I'm using Dev C++ by the way

At first, I had the following code:

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;

Inside my main.cpp, I did: #include "rapidxml_iterators.hpp" and gave me an expected nested-name specifier error when I tried to compile it. I followed the instructions from compile rapidxml under linux with g++ and changed the code from the top to the following:

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;

Now, it's giving me these errors:

-no class template named ptrdiff_t' in std' -ISO C++ forbids declaration of `difference_type' with no type

If anyone has any ideas on how to fix this code, I'd be forever grateful. Thanks in advance!

You lack the definition of std::ptrdiff_t . So the compiler tells you that you cannot typedef it since it is not defined.

Just include the proper header at the top of your file and you'll be good (with this error only!), that is, add:

#include <cstddef>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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