2013-03-06 18 views
0

我解析我的C++項目開發的C++ XML文件,我在rapidxml_iterators.hpp文件下面的代碼編譯錯誤錯誤:使用RapidXML在C++使用開發的C++

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++還是我的代碼的問題?謝謝

+0

請在此之前發佈錯誤以及您已經指定的任何包含文件。所有這些似乎都是診斷正在發生的事情所必需的。 – 2013-03-06 19:05:26

+0

@Kevin,我剛剛編輯了我的問題,幷包括我以前的錯誤和包含。希望這有幫助 – user2137877 2013-03-06 19:17:15

+0

你不需要在typedef中使用'typename'。您不使用從屬名稱。或者是模板內的這些typedefs? – dhavenith 2013-03-06 19:53:41

回答

1

之前,你做任何事情,嘗試刪除行: -

#include "rapidxml_iterators.hpp" 

它不是必需的 - 你可以完全使用rapidxml沒有它,從我記得它是很痛苦的來源和奇怪的編譯器錯誤。