2

次の単純なプログラムは、gcc 4.4.3 ではコンパイルできません。

#include "rapidxml.hpp"
#include "rapidxml_utils.hpp"
#include "rapidxml_print.hpp"
#include "rapidxml_iterators.hpp"

int main()
{
  return 0;
}

コンパイルすると次のエラーが発生します。

rapidxml_iterators.hpp:21: error: expected nested-name-specifier
rapidxml_iterators.hpp:21: error: invalid declarator before ‘value_type’
rapidxml_iterators.hpp:22: error: expected nested-name-specifier
rapidxml_iterators.hpp:22: error: invalid declarator before ‘&’ token
..........

私が間違っていることは何ですか?

4

3 に答える 3

1

これらのエラーは、rapidxml_iterators.hppヘッダーが原因で発生します。このヘッダーを含めることは、通常のxml解析には必要ないようです。どうやら、そこで定義されているイテレータはとにかく実際には使用できません。それはまだ開発中のものかもしれません。こちらもご覧ください

于 2010-12-15T10:58:45.983 に答える
1

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;
于 2011-07-04T09:01:06.067 に答える
0

Simple solution for simple case

You don't actually need rapidxml_iterators.hpp but were doing a sanity check, right ?

Solution: only #include the headers you actually need.

It's a general rule. #include'ing everything is like eating too much : it turns the situation fat and slow.

By contrast, including only what you need:

  • keeps you aware of your actual code dependency,
  • helps keeping you safe from namespace pollution and the occasional name clashes and sometimes even portability issues,
  • alerts you when you are starting to mess together things that should be kept separated.

If you really need rapidxml_iterators.hpp

At this point, the problem is probably solved. If you really need rapidxml_iterators.hpp, it's indeed buggy (looks like this particular error is a Microsoftism). This problem and others were reported on February 2010 on http://sourceforge.net/p/rapidxml/bugs/10/ with suggested solutions different from @user437634's, still open and present in current release as of July 2013.

于 2013-07-02T12:13:51.963 に答える