Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"tinyxml2.h" and windows.h #329

Open
BugIsComing opened this issue May 8, 2015 · 9 comments
Open

"tinyxml2.h" and windows.h #329

BugIsComing opened this issue May 8, 2015 · 9 comments

Comments

@BugIsComing
Copy link

Hello Leethomason.
when i use the tinyxml2, a error happens if i add the "tinyxml2.h" and windows.h in a cpp.Could you tell me why it happens please?

@Dmitry-Me
Copy link
Contributor

I guess more details of which error happens would be useful.

@BugIsComing
Copy link
Author

The error is "XMLDocument is redefinition".
I check the error, find that there is a definition of "class XMLDocument" in msxml.h.
The requirement is that i must add "tinyxml2.h" and windows.h in a same cpp,how can i deal with it?thank you!

@Dmitry-Me
Copy link
Contributor

Do you have using namespace tinyxml in your code?

@BugIsComing
Copy link
Author

yes, i do.

@kleuter
Copy link

kleuter commented May 17, 2015

Then you should not

@BugIsComing
Copy link
Author

ok,i'll think some other solutions.

@Dmitry-Me
Copy link
Contributor

IMO the obvious solution is to drop using namespace tinyxml.

@leethomason
Copy link
Owner

Just so others will know, does it work if you drop the using namespace tinyxml2. It should....but it would be good to confirm there isn't something more sinister going on.

@junmocklee
Copy link

It's old issue, but I think it can be helpful.

It works:

#include "tinyxml2.h"
#include <Windows.h>
using namespace tinyxml2;

It does not work;

#include "tinyxml2.h"
using namespace tinyxml2;
#include <Windows.h>

In my case, these also work:

#include "tinyxml2.h"

#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif

using namespace tinyxml2;
#include <Windows.h>
#include "tinyxml2.h"

#ifndef __MSXML_LIBRARY_DEFINED__
#define __MSXML_LIBRARY_DEFINED__
#endif

using namespace tinyxml2;
#include <Windows.h>

But this can be a problem when the project also use msxml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants