tinyxml2
tinyxml2 copied to clipboard
"tinyxml2.h" and windows.h
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?
I guess more details of which error happens would be useful.
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!
Do you have using namespace tinyxml
in your code?
yes, i do.
Then you should not
ok,i'll think some other solutions.
IMO the obvious solution is to drop using namespace tinyxml
.
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.
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.