I wanted to write a unicode version of std::exception and std::runtime_error.
So I thought what better way then to just take implementations from the C++ Standard Library and alter them to support unicode.
So I pulled up the exception and stdexcept headers in Visual C++, copied the code, made my changes.
The thing is I couldn’t get it to link unless I removed the _CRTIMP_PURE.
I also removed the _EXCEPTION_INLINE __CLR_OR_THIS_CALL prefix from all the member functions.
It’s working but I’m very curious what all those things did.
_EXCEPTION_INLINE it literally defined right above it as #define _EXCEPTION_INLINE, and my googling skills can’t find any documentation on what they do.
So, does anyone know what these are meant to do? And why it wound’t link until I removed the _CRTIMP_PURE prefix from the class?
These aren’t really anything mysterious (but it might be a bit pf a pain to track down where they’re defined – but only a little). They’re defined in headers that are part of the library, and they take on different definitions depending on how the compiler is configured for the current run. In particular, these macros seem to be concerned mostly with whether or not the current run is configured for
/clr:pure._CRTIMP_PUREis defined to__declspec(dllimport)if you’re linking against the DLL version of the C runtime (and not building with/clr:pure), and defined to nothing otherwise.If your library isn’t a DLL (or if it won’t necessarily be a DLL whenever the DLL runtime is configured), then you shouldn’t use it. You probably shouldn’t use it anyway, because you’d need to define it differently when building your library than when your library is being used (that’s what Microsoft does when they build the C runtime libraries).
__CLR_OR_THIS_CALLis used by Microsoft’s libraries to declare a function with__clrcallif you’re building with/clr:pure(indicating these functions will only be called by managed code – the compiler can perform certain optimizations in that case it seems).Finally,
_EXCEPTION_INLINEis used to make the member functions ofclass exceptioninlineif building with/clr:pure.So the bottom line is, don’t use
__CLR_OR_THIS_CALLor_EXCEPTION_INLINEunless you plan to support/clrfor your library, and you probably shouldn’t use_CRTIMP_PUREin your implementation, but probably should use something similar of your own making and under your own control.