0

I am parsing an XML file for my C++ project in Dev C++ and I have the following code in the rapidxml_iterators.hpp file:

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;

It is giving me these errors:

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

Prior to getting these errors, the code above was as follows:

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;

Which gave me the nested-name specifier errors like this:

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"

In my main file, which is where I'm doing the parsing, I have the following includes:

#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>

I have already looked around this website for similar posts and I have followed their advice but none of them have so far solved my problem. Is it a problem with Dev C++ or with my code? Thank you

6
  • Please post the errors before that as well, along with whatever include files you have already specified. All of that seems necessary to diagnose what's going on. Commented Mar 6, 2013 at 19:05
  • @Kevin, I just edited my question and included my previous errors and the includes. Hope this is helpful Commented Mar 6, 2013 at 19:17
  • you don't need typename in either typedef. You are not using dependant names. Or are these typedefs inside a template? Commented Mar 6, 2013 at 19:53
  • Yes, they are inside the template<class Ch> Commented Mar 6, 2013 at 20:07
  • I think we at least need some of your class declaration. Not necessarily everything if you have a reason not to tell us, but something "smells" wrong about how and where you are doing things. Also see if you can collapse your error down. Include only the files and lines barely needed to get something to compile that has the same error messages, then post that. Like "without these lines, it compiles, but with them, it fails!" and give the rest as well. You should be able to get it down to very few lines. Commented Mar 6, 2013 at 22:55

1 Answer 1

2

Before you do anything else, try and remove the line:-

#include "rapidxml_iterators.hpp"

It's not normally necessary - you can use rapidxml perfectly without it, and from what I recall it's a source of much pain and weird compiler errors.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.