Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Prevent mixing debug and release libraries
- //header:
- class DLLIMPEXP Dummy
- {
- static int x;
- virtual void dummy();
- }
- //cpp
- #ifdef DEBUG
- int Dummy::x = 0;
- void Dummy::dummy()
- {
- }
- #endif
- #ifdef NDEBUG
- namespace project {
- #else
- namespace project { namespace debug {
- #endif
- // content
- #ifdef NDEBUG
- }
- #else
- }
- using namespace debug;
- }
- #endif
- myLib.h // Release Version
- myLibd.h // Debug Version
- #ifndef _DLL
- // C runtime as dll
- # ifdef _DEBUG
- # pragma comment(lib, "MyLibD.lib")
- # else
- # pragma comment(lib, "MyLib.lib")
- # endif
- #else
- // C runtime statically
- # ifdef _DEBUG
- # pragma comment(lib, "MyLibSD.lib")
- # else
- # pragma comment(lib, "MyLibS.lib")
- # endif
- #endif
- #ifndef _DLL
- // C runtime as dll
- # ifdef _DEBUG
- # pragma comment(lib, "debug/dynamic/MyLib.lib")
- # else
- # pragma comment(lib, "release/dynamic/MyLib.lib")
- # endif
- #else
- // C runtime statically
- # ifdef _DEBUG
- # pragma comment(lib, "debug/static/MyLib.lib")
- # else
- # pragma comment(lib, "debug/static/MyLib.lib")
- # endif
- #endif
Add Comment
Please, Sign In to add comment