8BIT wrote:
Code:
#ifndef nullptr
#define nullptr ((TCHAR*)0)
#endif
That's not right.
In C++11 and later nullptr is a keyword (not a macro, so the preprocessor won't know about it). And #defining keywords is not permitted. So that code, while it might compile and work, is technically illegal under C++11.
Before C++11 we had NULL, which is defined to be the literal 0 (or "an integral constant expression rvalue of integer type that evaluates to zero"). It's only C that wants it to be cast to a pointer type.
I can't find an accurate way to test whether a compiler supports nullptr or not. __cplusplus is the closest, but that can still cause problems: some versions of VC++ supported some but not all of C++11, so they had nullptr but __cplusplus still reported an earlier standard. And gcc had it defined as 1 for a while. So the best I can suggest is
Code:
#if __cplusplus < 201100
#define nullptr NULL
#endif
If that causes problems with one particular compiler, find a way of identifying it and include that in the condition.
(and this is not "some strange Microsoft drivel". It's C++ adding features with no reliable way of testing for their presence, people still using very old compilers, and what looks like a third party library of unknown quality)