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

  1. /***
  2. *new.h - declarations and definitions for C++ memory allocation functions
  3. *
  4. *       Copyright (c) 1990-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       Contains the declarations for C++ memory allocation functions.
  8. *
  9. *       [Public]
  10. *
  11. ****/
  12.  
  13. #if     _MSC_VER > 1000
  14. #pragma once
  15. #endif
  16.  
  17. #ifndef _INC_NEW
  18. #define _INC_NEW
  19.  
  20. #ifdef  __cplusplus
  21.  
  22. #ifndef _MSC_EXTENSIONS
  23. #include <new>
  24. #endif
  25.  
  26. #if     !defined(_WIN32) && !defined(_MAC)
  27. #error ERROR: Only Mac or Win32 targets supported!
  28. #endif
  29.  
  30.  
  31.  
  32.  
  33. /* Define _CRTIMP */
  34.  
  35. #ifndef _CRTIMP
  36. #ifdef  _DLL
  37. #define _CRTIMP __declspec(dllimport)
  38. #else   /* ndef _DLL */
  39. #define _CRTIMP
  40. #endif  /* _DLL */
  41. #endif  /* _CRTIMP */
  42.  
  43.  
  44. /* Define __cdecl for non-Microsoft compilers */
  45.  
  46. #if     ( !defined(_MSC_VER) && !defined(__cdecl) )
  47. #define __cdecl
  48. #endif
  49.  
  50. /* Define _CRTAPI1 (for compatibility with the NT SDK) */
  51.  
  52. #ifndef _CRTAPI1
  53. #if    _MSC_VER >= 800 && _M_IX86 >= 300
  54. #define _CRTAPI1 __cdecl
  55. #else
  56. #define _CRTAPI1
  57. #endif
  58. #endif
  59.  
  60.  
  61. /* types and structures */
  62.  
  63. #ifndef _SIZE_T_DEFINED
  64. typedef unsigned int size_t;
  65. #define _SIZE_T_DEFINED
  66. #endif
  67.  
  68. #ifdef  _MSC_EXTENSIONS
  69. typedef void (__cdecl * new_handler) ();
  70. _CRTIMP new_handler __cdecl set_new_handler(new_handler);
  71. #endif
  72.  
  73. #ifndef __PLACEMENT_NEW_INLINE
  74. #define __PLACEMENT_NEW_INLINE
  75. inline void *__cdecl operator new(size_t, void *_P)
  76.         {return (_P); }
  77. #if     _MSC_VER >= 1200
  78. inline void __cdecl operator delete(void *, void *)
  79.     {return; }
  80. #endif
  81. #endif
  82.  
  83.  
  84. /* 
  85.  * new mode flag -- when set, makes malloc() behave like new()
  86.  */
  87.  
  88. _CRTIMP int __cdecl _query_new_mode( void );
  89. _CRTIMP int __cdecl _set_new_mode( int );
  90.  
  91. #ifndef _PNH_DEFINED
  92. typedef int (__cdecl * _PNH)( size_t );
  93. #define _PNH_DEFINED
  94. #endif
  95.  
  96. _CRTIMP _PNH __cdecl _query_new_handler( void );
  97. _CRTIMP _PNH __cdecl _set_new_handler( _PNH );
  98.  
  99. /*
  100.  * Microsoft extension: 
  101.  *
  102.  * _NO_ANSI_NEW_HANDLER de-activates the ANSI new_handler. Use this special value
  103.  * to support old style (_set_new_handler) behavior.
  104.  */
  105.  
  106. #ifndef _NO_ANSI_NH_DEFINED
  107. #define _NO_ANSI_NEW_HANDLER  ((new_handler)-1)
  108. #define _NO_ANSI_NH_DEFINED
  109. #endif
  110.  
  111. #endif /* __cplusplus */
  112.  
  113. #endif /* _INC_NEW */
  114.