I assume that you are using a static library, and binary you mean .lib, which will be linked at compile time (as opposed to DLLs or the like, which may not be compatible at runtime).
It seems to me that the easiest way is to have this construct in your .h file
#ifdef _RELEASE //or whatever your compiler uses #define InitialiseLibrary InitialiseLibraryRelease #else #define InitialiseLibrary InitialiseLibraryDebug #endif
Similarly in the cpp library file:
#ifdef _RELEASE
Now in the main exe that uses the library:
InitialiseLibrary();
If the liberation of the library and exe don; t match, then the linker will report that it does not match a particular InitialiseLibrary function ...
Another option is to make sure that the release and debug libraries are compiled with named files, and then get a link to work using #pragma in the .h file (as opposed to explicitly including the library in the project). Using #ifdef, as described above, you can choose at compile time which library to link by choosing which #pragma is used. This second method does not exactly solve your question (since it does not stop the connection if the programmer tries to force it), but it is a common way to deal with this kind of difficulties (and has advantages in complex build environments)
source share