Problem with TinyXML #include ... Using Libraries

Hey, I'm really trying to get TinyXML to at least read the file, but it says: "main.cpp: 8: error:" TiXMLDocument has not been declared in this area "

This is the im code using:

TiXMLDocument("demo.xml");

Ideally, I want to read the ability to read files and output XML, so I also tried this code, which I found online in the tutorial

#include <iostream>

#include "tinyxml.h"
#include "tinystr.h"

void dump_to_stdout(const char* pFilename)
{
    TiXmlDocument doc(pFilename);
    bool loadOkay = doc.LoadFile();
    if (loadOkay)
    {
        printf("\n%s:\n", pFilename);
        dump_to_stdout( &doc ); // defined later in the tutorial
    }
    else
    {
        printf("Failed to load file \"%s\"\n", pFilename);
    }
}

int main(void)
{
    dump_to_stdout("demo.xml");
    return 0;
}

And now I get the following errors:

main.cpp: In function ‘void dump_to_stdout(const char*)’:
main.cpp:13: error: cannot convert ‘TiXmlDocument*’ to ‘const char*’ for argument ‘1’ to ‘void dump_to_stdout(const char*)’

If that helps im on mac, ive tried compiling in terminal as well as in textmate. I also tried to compile the cpp files for TinyXML separately before compiling main.cpp, and I have no idea why I cannot print demo.xml, not to mention reading it.

+3
source share
3
  • TiXmlDocument, TiXmlDocument
  • , . dump_to_stdout, , , const char * .
+1
dump_to_stdout( &doc ); // defined later in the tutorial

.

  • dump_to_stdout const char*, TiXmlDocument .
  • , .
  • , , TiXmlDocument. dump_to_stdout, , , . , , , : void dump_to_stdout(TiXmlDocument*);
0

Maybe I misunderstood something, but the problem is not solved. dump_to_stdout (& doc); causes error C2664. void dump_to_stdout (TiXmlDocument *); causes LNK2019 errors and LNK2001 errors. Could you help me please solve this problem for proper compilation. enter image description here

0
source

Source: https://habr.com/ru/post/1787662/


All Articles