home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / assert.h < prev    next >
C/C++ Source or Header  |  1998-06-17  |  2KB  |  86 lines

  1. /***
  2. *assert.h - define the assert macro
  3. *
  4. *       Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       Defines the assert(exp) macro.
  8. *       [ANSI/System V]
  9. *
  10. *       [Public]
  11. *
  12. ****/
  13.  
  14. #if !defined (_WIN32) && !defined (_MAC)
  15. #error ERROR: Only Mac or Win32 targets supported!
  16. #endif  /* !defined (_WIN32) && !defined (_MAC) */
  17.  
  18. #ifndef _CRTBLD
  19. /* This version of the header files is NOT for user programs.
  20.  * It is intended for use when building the C runtimes ONLY.
  21.  * The version intended for public use will not have this message.
  22.  */
  23. #error ERROR: Use of C runtime library internal header file.
  24. #endif  /* _CRTBLD */
  25.  
  26. #ifndef _INTERNAL_IFSTRIP_
  27. #ifndef _ASSERT_OK
  28. #error assert.h not for CRT internal use, use dbgint.h
  29. #endif  /* _ASSERT_OK */
  30. #include <cruntime.h>
  31. #endif  /* _INTERNAL_IFSTRIP_ */
  32.  
  33.  
  34. /* Define _CRTIMP */
  35.  
  36. #ifndef _CRTIMP
  37. #ifdef CRTDLL
  38. #define _CRTIMP __declspec(dllexport)
  39. #else  /* CRTDLL */
  40. #ifdef _DLL
  41. #define _CRTIMP __declspec(dllimport)
  42. #else  /* _DLL */
  43. #define _CRTIMP
  44. #endif  /* _DLL */
  45. #endif  /* CRTDLL */
  46. #endif  /* _CRTIMP */
  47.  
  48.  
  49. /* Define __cdecl for non-Microsoft compilers */
  50.  
  51. #if (!defined (_MSC_VER) && !defined (__cdecl))
  52. #define __cdecl
  53. #endif  /* (!defined (_MSC_VER) && !defined (__cdecl)) */
  54.  
  55. /* Define _CRTAPI1 (for compatibility with the NT SDK) */
  56.  
  57. #ifndef _CRTAPI1
  58. #if _MSC_VER >= 800 && _M_IX86 >= 300
  59. #define _CRTAPI1 __cdecl
  60. #else  /* _MSC_VER >= 800 && _M_IX86 >= 300 */
  61. #define _CRTAPI1
  62. #endif  /* _MSC_VER >= 800 && _M_IX86 >= 300 */
  63. #endif  /* _CRTAPI1 */
  64.  
  65. #undef  assert
  66.  
  67. #ifdef NDEBUG
  68.  
  69. #define assert(exp)     ((void)0)
  70.  
  71. #else  /* NDEBUG */
  72.  
  73. #ifdef __cplusplus
  74. extern "C" {
  75. #endif  /* __cplusplus */
  76.  
  77. _CRTIMP void __cdecl _assert(void *, void *, unsigned);
  78.  
  79. #ifdef __cplusplus
  80. }
  81. #endif  /* __cplusplus */
  82.  
  83. #define assert(exp) (void)( (exp) || (_assert(#exp, __FILE__, __LINE__), 0) )
  84.  
  85. #endif  /* NDEBUG */
  86.