There are two different aspects to this:
- incompatibility problem
- performance issue
If this is a performance issue, then the choice will still be theirs, they may want to debug.
If this is a matter of incompatibility, one simple thing is to change the namespace for the debug version so that the characters will be distorted in different ways.
#ifdef NDEBUG namespace project { #else namespace project { namespace debug { #endif
Nested in the debug
namespace, you change the character binding (although, compiled, it doesn't change anything). This actually prevents linking the library compiled against the debug version with the release version (and thus solves incompatibility at an early stage, rather than crashing mysteriously).
However, I would strongly recommend that you reserve this for a very specific set of classes (this is hard).
As a general rule, it should be possible to provide compatible interfaces in both debug and release modes so that clients can be hot-swappable at boot time.
source share