Git Product home page Git Product logo

Comments (6)

leethomason avatar leethomason commented on June 30, 2024

You can use:
#define WIN32_LEAN_AND_MEAN
#include windows.h

to exclude the windows XML headers. Or this should work (although I haven't confirmed):
tinyxml2::XMLDocument

I don't know a concise solution if you are using the full windows headers and don't want to append the tinyxml2:: everywhere. I'm hoping someone else may know.

from tinyxml2.

gamaral avatar gamaral commented on June 30, 2024

@jelemans You're probably importing/using the full namespace, not a good idea (on windows). I would suggest aliasing the namespace, for example:

 namespace TinyXML = tinyxml2;
 namespace TXML = tinyxml2;
 ...
 TinyXML::XMLDocument ...
 TXML::XMLDocument ...

That way it at least looks pretty. :)

from tinyxml2.

toolchainX avatar toolchainX commented on June 30, 2024

I come across the same problem and I solved it like this, in the tinyxml2.cpp brace all the code in the namespace tinyxml2 like this:

#include "tinyxml2.h"

#if 1
#include <cstdio>
#include <cstdlib>
#include <new>
#else
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <new>
#include <stdarg.h>
#endif
namespace tinyxml2
{
    class XMLDocument;
    class XMLElement;
    class XMLAttribute;
    class XMLComment;
    class XMLNode;
    class XMLText;
    class XMLDeclaration;
    class XMLUnknown;
    class XMLPrinter;

    // the previous code in this file

}  // namespace tinyxml2
// end of the file 

from tinyxml2.

kainjow avatar kainjow commented on June 30, 2024

I just came across this same issue. I used the idea from @tlh1987 by enclosing the code in the namespace.

Code compiles now on VS 2010, clang 4.1 (OS X) and gcc 4.6.3 (Linux).

from tinyxml2.

wensonsmith avatar wensonsmith commented on June 30, 2024

@kainjow It dose't work for me , I download the latest version and have added using namespace tinyxml2; to my cpp file.

Compiles on VS2010 Win7 (64Bit) , It's still report the error

from tinyxml2.

kainjow avatar kainjow commented on June 30, 2024

I wouldn't use 'using namespace', kind of defeats the purpose of namespaces in the first place. Just use tinyxml2::XMLDocument, etc.

from tinyxml2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.