2

Good evening, I try to use tinyxml 2 with my C++ builder IDE. The code is really simple. I only want to parse an existing XML-File. The Code looks like this:

#include "tinyxml2.h"
using namespace tinyxml2;

class myclass
{
  XMLDocument doc_;
}

And now the compiler gives the messages: "reference to XMLDocument is ambiguous"

Any ideas? I don't know how to fix this. Thank you very much for your tipps.

Ted Lyngmo
  • 93,841
  • 5
  • 60
  • 108
Hoeh
  • 45
  • 4
  • 2
    there's a semicolon missing at the end of the file. Not sure though if this fixes anything. – fabian Mar 14 '21 at 17:18
  • Don't do `using namespace tinyxml2;` in your header file. Instead, type it out `tinyxml2::XMLDocument doc_;` – Ted Lyngmo Mar 14 '21 at 17:22
  • I tried this too. But then i receive an error from the linker. – Hoeh Mar 14 '21 at 17:27
  • That's better so keep it like that. You probably don't link with the `tinyxml2` library. – Ted Lyngmo Mar 14 '21 at 17:39
  • I can't reproduce your issue in 10.3.3. Have you tried a project with just xmltest.cpp and tinyxml2.cpp ? This compiles and runs in 10.3.3 for both Win32 and Win64. Creating a second project with your code plus the missing semicolon, plus main, also compiled and ran. – Paul McGee Mar 15 '21 at 16:34
  • If I don't prefix the `XMLDocument` with the `tinyxml2` prefix then I also get the ambiguous calls because it does not know which of the classes to use. So that should help and did you try a full compile? Try a test console project to reproduce. – Andrew Truckle Mar 21 '21 at 08:49

0 Answers0