I am writing a managed wrapper in C++/CLI (VS2010) for a third-party unmanaged library. In the code, I have a method that looks like this:
if(oldState != _state && UnitStateChanged != nullptr)
UnitStateChanged(this, gcnew UnitStateChangedEventArgs(oldState, _state));
The “nullptr” generates the following error:
error C2446: ‘!=’ : no conversion from ‘int’ to ‘UnitStateChangedEventHandler ^’
The compiler seems to treat any use of “nullptr” as an “int”, even on something as simple as this:
Object^ temp = nullptr;
Everything i’ve read indicates that the compiler will figure it out on it’s own, but that doesn’t seem to be the case. Is there a setting that I’m missing (other than /clr or #pragma managed)?
Someone without a C++11 compiler wrote
somewhere in a header file?
(The usual macro is
#define NULL (0))This is, of course, forbidden.