Code: Select all
error C2535: 'irr::io::xmlChar<T>::xmlChar(wchar_t)' : member function already defined or declared d:\developing\projects\imt\api\3rd_party\irrlicht-1.8.1\include\irrXML.h
Code: Select all
error C2535: 'irr::io::xmlChar<T>::xmlChar(wchar_t)' : member function already defined or declared d:\developing\projects\imt\api\3rd_party\irrlicht-1.8.1\include\irrXML.h
Code: Select all
explicit xmlChar<T>(unsigned short in) : c(static_cast<T>(in)) {}
Code: Select all
#ifndef QGLOBAL_H
explicit xmlChar<T>(unsigned short in) : c(static_cast<T>(in)) {}
#endif
Your suggestion is irrelevant for four reasons.CuteAlien wrote:This sounds very wrong. You don't add random defines in library headers. But can't help without knowing anything about your code. Try to start with the examples coming with Irrlicht as first step. Once those compile you know the engine works basically and you can go on working on own projects then.
Code: Select all
struct xmlChar
{
T c;
xmlChar<T>() {}
xmlChar<T>(char in) : c(static_cast<T>(in)) {}
xmlChar<T>(wchar_t in) : c(static_cast<T>(in)) {} // NOTICE the wchar_t version here
#if defined(__BORLANDC__)
// Note - removing explicit for borland was to get it to even compile.
// There haven't been any kind of tests for that besides that.
xmlChar<T>(unsigned char in) : c(static_cast<T>(in)) {}
xmlChar<T>(unsigned short in) : c(static_cast<T>(in)) {}
xmlChar<T>(unsigned int in) : c(static_cast<T>(in)) {}
xmlChar<T>(unsigned long in) : c(static_cast<T>(in)) {}
#else
explicit xmlChar<T>(unsigned char in) : c(static_cast<T>(in)) {}
explicit xmlChar<T>(unsigned short in) : c(static_cast<T>(in)) {} //THIS LINE causes the compile error
explicit xmlChar<T>(unsigned int in) : c(static_cast<T>(in)) {}
explicit xmlChar<T>(unsigned long in) : c(static_cast<T>(in)) {}
#endif
operator T() const { return c; }
void operator=(int t) { c=static_cast<T>(t); }
};
Code: Select all
struct xmlChar
{
T c;
xmlChar<T>() {}
xmlChar<T>(char in) : c(static_cast<T>(in)) {}
#ifndef QGLOBAL_H
xmlChar<T>(wchar_t in) : c(static_cast<T>(in)) {} // prevents wchar_t use in Qt ONLY!!!
#endif
#if defined(__BORLANDC__)
// Note - removing explicit for borland was to get it to even compile.
// There haven't been any kind of tests for that besides that.
xmlChar<T>(unsigned char in) : c(static_cast<T>(in)) {}
xmlChar<T>(unsigned short in) : c(static_cast<T>(in)) {}
xmlChar<T>(unsigned int in) : c(static_cast<T>(in)) {}
xmlChar<T>(unsigned long in) : c(static_cast<T>(in)) {}
#else
explicit xmlChar<T>(unsigned char in) : c(static_cast<T>(in)) {}
explicit xmlChar<T>(unsigned short in) : c(static_cast<T>(in)) {}
explicit xmlChar<T>(unsigned int in) : c(static_cast<T>(in)) {}
explicit xmlChar<T>(unsigned long in) : c(static_cast<T>(in)) {}
#endif
operator T() const { return c; }
void operator=(int t) { c=static_cast<T>(t); }
};
But... it isn't sharing defines. It is only checking to see if a define exists. If the define doesn't exist, then the compiler interprets the #ifndef as if it doesn't exist...CuteAlien wrote:Interesting problem, but I guess you misunderstood me. The wrong part is not about adding some kind of check - but adding a check for one library in a header of another. That's kind of random as it would connect completely independent libraries to each other by sharing defines.
No... not if you want the solution to be portable. But I don't need it to be.CuteAlien wrote:Just not something that should ever be done.
Effectively... this is what I have done, albeit in a non-portable way.CuteAlien wrote:The nicest one would be to figure out at compile-time already if unsigned short is identical to wchar_t somehow and then exclude it. Not sure if that's possible. The other one would likely be adding a define in Irrlicht which allows re-defining wchar_t the same way as qt (or cmake) seem to do in this case and exclude the line when that define is used. But that would not be default - so you'd never get around recompiling one of the libs.