tags:

views:

427

answers:

3

Hi,

I am novice to rapidXML but first impresion was not positive, I made simple Visual Studio 6 C++ Hello World Application and added RapidXML hpp files to project and in main.cpp I put:

#include "stdafx.h"

#include < iostream >
#include < string >
#include "rapidxml.hpp"

using namespace std;
using namespace rapidxml;

int main ( )
{
    char x[] = "<Something>Text</Something>\0" ; //<<<< funktioniert, aber mit '*' nicht
    xml_document<> doc ;
    doc.parse<0>(x) ;
    cout << "Name of my first node is: " << doc.first_node()->name() << endl ;
    xml_node<>* node = doc.first_node("Something") ;
    cout << "Node 'Something' has value: " << node->value() << endl ;
} 

And it does not compile, any help ? Is RapidXML possible to run with Visual Studio 6 ? Error I am getting are:

--------------------Configuration: aaa - Win32 Debug--------------------
Compiling...
rapidxml.cpp
c:\Parser\rapidxml.cpp(310) : error C2039: 'size_t' : is not a member of 'std'
c:\Parser\rapidxml.cpp(320) : error C2039: 'size_t' : is not a member of 'std'
c:\Parser\rapidxml.cpp(320) : error C2039: 'size_t' : is not a member of 'std'
c:\Parser\rapidxml.cpp(385) : error C2039: 'size_t' : is not a member of 'std'
        c:\Parser\rapidxml.cpp(639) : see reference to class template instantiation 'rapidxml::memory_pool<Ch>' being compiled
c:\Parser\rapidxml.cpp(417) : error C2039: 'size_t' : is not a member of 'std'
        c:\Parser\rapidxml.cpp(639) : see reference to class template instantiation 'rapidxml::memory_pool<Ch>' being compiled
c:\Parser\rapidxml.cpp(417) : error C2039: 'size_t' : is not a member of 'std'
        c:\Parser\rapidxml.cpp(639) : see reference to class template instantiation 'rapidxml::memory_pool<Ch>' being compiled
c:\Parser\rapidxml.cpp(448) : error C2039: 'size_t' : is not a member of 'std'
        c:\Parser\rapidxml.cpp(639) : see reference to class template instantiation 'rapidxml::memory_pool<Ch>' being compiled
c:\Parser\rapidxml.cpp(448) : error C2039: 'size_t' : is not a member of 'std'
        c:\Parser\rapidxml.cpp(639) : see reference to class template instantiation 'rapidxml::memory_pool<Ch>' being compiled
c:\Parser\rapidxml.cpp(476) : error C2039: 'size_t' : is not a member of 'std'
        c:\Parser\rapidxml.cpp(639) : see reference to class template instantiation 'rapidxml::memory_pool<Ch>' being compiled
c:\Parser\rapidxml.cpp(579) : error C2039: 'size_t' : is not a member of 'std'
        c:\Parser\rapidxml.cpp(639) : see reference to class template instantiation 'rapidxml::memory_pool<Ch>' being compiled
c:\Parser\rapidxml.cpp(599) : error C2039: 'size_t' : is not a member of 'std'
        c:\Parser\rapidxml.cpp(639) : see reference to class template instantiation 'rapidxml::memory_pool<Ch>' being compiled
c:\Parser\rapidxml.cpp(681) : error C2039: 'size_t' : is not a member of 'std'
        c:\Parser\rapidxml.cpp(790) : see reference to class template instantiation 'rapidxml::xml_base<Ch>' being compiled
c:\Parser\rapidxml.cpp(700) : error C2039: 'size_t' : is not a member of 'std'
        c:\Parser\rapidxml.cpp(790) : see reference to class template instantiation 'rapidxml::xml_base<Ch>' being compiled
c:\Parser\rapidxml.cpp(721) : error C2039: 'size_t' : is not a member of 'std'
        c:\Parser\rapidxml.cpp(790) : see reference to class template instantiation 'rapidxml::xml_base<Ch>' being compiled
c:\Parser\rapidxml.cpp(751) : error C2039: 'size_t' : is not a member of 'std'
        c:\Parser\rapidxml.cpp(790) : see reference to class template instantiation 'rapidxml::xml_base<Ch>' being compiled
c:\Parser\rapidxml.cpp(786) : error C2039: 'size_t' : is not a member of 'std'
        c:\Parser\rapidxml.cpp(790) : see reference to class template instantiation 'rapidxml::xml_base<Ch>' being compiled
c:\Parser\rapidxml.cpp(787) : error C2039: 'size_t' : is not a member of 'std'
        c:\Parser\rapidxml.cpp(790) : see reference to class template instantiation 'rapidxml::xml_base<Ch>' being compiled
c:\Parser\rapidxml.cpp(836) : error C2039: 'size_t' : is not a member of 'std'
        c:\Parser\rapidxml.cpp(876) : see reference to class template instantiation 'rapidxml::xml_attribute<Ch>' being compiled
c:\Parser\rapidxml.cpp(856) : error C2039: 'size_t' : is not a member of 'std'
        c:\Parser\rapidxml.cpp(876) : see reference to class template instantiation 'rapidxml::xml_attribute<Ch>' being compiled
c:\Parser\rapidxml.cpp(936) : error C2039: 'size_t' : is not a member of 'std'
        c:\Parser\rapidxml.cpp(1345) : see reference to class template instantiation 'rapidxml::xml_node<Ch>' being compiled
c:\Parser\rapidxml.cpp(958) : error C2039: 'size_t' : is not a member of 'std'
        c:\Parser\rapidxml.cpp(1345) : see reference to class template instantiation 'rapidxml::xml_node<Ch>' being compiled
c:\Parser\rapidxml.cpp(981) : error C2039: 'size_t' : is not a member of 'std'
        c:\Parser\rapidxml.cpp(1345) : see reference to class template instantiation 'rapidxml::xml_node<Ch>' being compiled
c:\Parser\rapidxml.cpp(1004) : error C2039: 'size_t' : is not a member of 'std'
        c:\Parser\rapidxml.cpp(1345) : see reference to class template instantiation 'rapidxml::xml_node<Ch>' being compiled
c:\Parser\rapidxml.cpp(1025) : error C2039: 'size_t' : is not a member of 'std'
        c:\Parser\rapidxml.cpp(1345) : see reference to class template instantiation 'rapidxml::xml_node<Ch>' being compiled
c:\Parser\rapidxml.cpp(1045) : error C2039: 'size_t' : is not a member of 'std'
        c:\Parser\rapidxml.cpp(1345) : see reference to class template instantiation 'rapidxml::xml_node<Ch>' being compiled
Error executing cl.exe.

rapidxml.obj - 25 error(s), 0 warning(s)
+1  A: 

Visual C++ 6 dates back to before the C++ language was standardised. If you are having problems compiling even vaguely modern code with it, the chances are the problem lies with the compiler and not the code. Such problems cannot usually be fixed - you probably need to upgrade to a more modern compiler.

anon
Since I am just novice in this parsig business, I do exect that this is my bug... let see what the others thinks.
milan
@milan The error is that VC++ 6.0 apparently cannot compile RapidXM, nothing to do with your own codeL. Seeing as the RapidXML project started 8 years after VC++ 6 was released, this is not surprising. It doesn't matter what "the others" think.
anon
Getting the new Visual Studio comes with cost ... so I would rather wait for any other opinions :)
milan
i still did not check but information I got are like you Neil told me ..it seems that compiler is too old.
milan
A: 

It's not technically legal, but could you try inserting the following code above your #include "rapidxml.hpp" line:

namespace std
{
    typedef unsigned long size_t;
}

This will (illegally) inject size_t into the std namespace before RapidXML tries to use it. If that actually compiles, then you can search through the VC6 header files to find out what the real definition of size_t is and replace unsigned long above.

Kristo
I am not allowed to send complete error list but i got this(I put what you said first in main and than in rapidxml.hpp file):rapidxml.cpprapidxml_iterators.cppc:\_milan\tools\aaa\rapidxml_iterators.cpp(24) : error C2039: 'ptrdiff_t' : is not a member of 'std' c:\_milan\tools\aaa\rapidxml_iterators.cpp(91) : see reference to class template instantiation 'rapidxml::node_iterator<Ch>' being compiled
milan
I think `ptrdiff_t` is probably the same as `size_t`. Add another typedef to your namespace and try again.
Kristo
+2  A: 

I just noticed your errors relate to rapidxml.cpp. Where's that file come from??

RapidXML is a header-only library. There is no rapidxml.cpp, and rapidxml.hpp cannot be compiled on it's own - you just include it in your own files (like in main.cpp above) to use it.

I know nothing about VC++, but try removing "rapidxml" from the VC project and rebuild.

Roddy
i renamed rapidxml.hpp in cpp is that wrong? At the end it should be compliled with the same compiler, right ?I removed from the main.cpp "using namespace rapidxml;" as you told but and still got errors:Deleting intermediate files and output files for project 'RapidXMLParser - Win32 Debug'.--------------------Configuration: RapidXMLParser - Win32 Debug--------------------Compiling...main.cppc:\_milan\tools\rapidxmlparser\rapidxml.hpp(312) : error C2039: 'size_t' : is not a member of 'std'c:\_milan\tools\rapidxmlparser\rapidxml.hpp(322) : error C2039: 'size_t' : is not a member of 'std'
milan
@milan: "i renamed rapidxml.hpp in cpp is that wrong?" Yes. 100% wrong. *IT IS JUST A HEADER FILE. THAT IS ALL YOU NEED*. By "removing rapidxml" I mean *remove file rapidxml.cpp from the VS project, NOT remove the 'using namespace rapidxml' line.
Roddy
Compiling works now but function from the main file:doc.first_node()->name()gives exception (access violation). When I debug-in exception happens in function: Ch *name() const { return m_name ? m_name : nullstr(); }where variable m_name in debuger shows following value:m_name CXX0030: Error: expression cannot be evaluatedAny clue what is wrong in this simple case?br,milan.
milan