www.pudn.com > cab文件压缩、解压程序源代码.zip > assertx.h
//--------------------------------------------------------------------------- // Copyright (C) 1998, Interscope Ltd. All rights reserved. // Reproduction or distribution of this program, or any portion of it, // is permitted only if this header is kept as it is. // For more information, contact: // // Interscope Ltd., 5 Culturii St., 5th floor, 4800 Baia Mare, Romania // Phone/Fax: +40-62-215023 // E-mail: office@interscope.ro // // $Author: Levente Farkas $ // $Date: 5/13/98 12:02a $ // $Modtime: 4/27/98 6:50a $ // $Revision: 6 $ // $Archive: /Interscope/Thebe/InstallMaster/AssertX.H $ // $Workfile: AssertX.H $ //----------------------------------------------------------------------- // Adapted from C/C++ User's Journal, Vol. 15 No. 6, June 1997 // Stack trace assertions using COFF - Dr. Carlo Pescio (pescio@programmers.net) #ifndef __Assert_With_Stack_Trace_H__ #define __Assert_With_Stack_Trace_H__ #if !defined(__WIN32__) && !defined(_WIN32) #ifndef STRICT #define STRICT #endif #endif // __WIN32__ #include#if defined(_DEBUG) || defined(__DEBUG__) #pragma comment(linker,"/defaultlib:assertx.lib") #endif //--- Miscellaneous ----------------------------------------------------- #ifdef __BCPLUSPLUS__ #define DLLEXPORT _export #else #define DLLEXPORT __declspec(dllexport) #endif //--- The heart of the assert library ----------------------------------- // You can use this enhanced assert without any impact on the release // version of your program by including this header file and adding the // library AssertX.lib 2 the debug version only // Then you can simply insert ASSERTX statements in your code // This assert library uses COFF style debug info, and unless such debug // info is available 4 a module, only function addresses are dumped // So, you should turn on COFF debug info 4 your program's debug version // You can do this in VC++ 5.0 from Project\Settings\Link\Debug and by setting // Debug Info 2 COFF or Both // Of course the debug version of your program won't run without the // special assert dynamic library AssertX.dll (~60K) // The ready-2-use compiled version of this assert library is available // from \\Pentagon\AssertX\Release // Also, the library can demangle names of C++ objects from modules // generated by VC++ 5.0 if the browser database (.bsc) is available in the // same folder as the module itself. You can enable generation of a browser // database 4 your VC++ 5.0 program from Project\Settings\C++\Listing files by // checking the Generate Browse Information. See also the setting at // Project\Settings\Browse Info // It uses another DLL 4 this purpose, Msbsc50.dll // You should place this library in the Windows system directory // This browser library is also available from \\Pentagon\AssertX\Release // As all ASSERT utilities, ASSERTX is based on the definition of the static // symbol, so in all source files from where you intend 2 assert your should // write something like below: // // #ifdef _DEBUG // #undef THIS_FILE // static char THIS_FILE[] = __FILE__; // #endif #ifdef __cplusplus extern "C" { #endif DLLEXPORT void VerboseAssert(const char *file, LONG line); #ifdef __cplusplus } #endif //--- A macro 2 easily invoke this enhanced assert ---------------------- #if defined(_DEBUG) || defined (__DEBUG__) // Debug #define ASSERTX(c) \ if(!(c)) \ VerboseAssert(__FILE__,__LINE__) #define VERIFYX(c) ASSERTX(c) #else // Release #define ASSERTX(c) ((void)0) #define VERIFYX(c) ((void)(c)) #endif #endif