This is my assert function (it wont compile "error C2110: '+' : cannot add two pointers"):
#define CHAR(x) #x
template<typename T>
inline void ASSERT(T x)
{
if(!x)
{
std::string s("ERROR! Assert " + CHAR(x) + " failed. In file " + __FILE__ +
" at line " + __LINE__ + ".");
std::wstring temp(s.length(), L' ');
std::copy(s.begin(), s.end(), temp.begin());
getLogger().Write(temp);
}
}
Any idea of how to fix it?
__FILE__and__LINE__require that it is implemented as a macro (assuming you want the file and line in which theASSERTis used).__FILE__and__LINE__are preprocessor macros which will be "magically" replaced by constants later.std::string. Then this entire issue just disintegrates. (This means that each [sort of] string literal in your code should be wrapped in a temporary instantiation ofstd::string; then you can rely onstd::string'sop+to do the heavy lifting for you.) In this case, as others have said, you can just rely on preprocessor concatenation, but this won't always be available to you.