home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / new.h < prev    next >
C/C++ Source or Header  |  1998-06-17  |  3KB  |  128 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  /* _MSC_VER > 1000 */
  16.  
  17. #ifndef _INC_NEW
  18. #define _INC_NEW
  19.  
  20. #ifdef __cplusplus
  21.  
  22. #ifndef _MSC_EXTENSIONS
  23. #include <new>
  24. #endif  /* _MSC_EXTENSIONS */
  25.  
  26. #if !defined (_WIN32) && !defined (_MAC)
  27. #error ERROR: Only Mac or Win32 targets supported!
  28. #endif  /* !defined (_WIN32) && !defined (_MAC) */
  29.  
  30. #ifndef _CRTBLD
  31. /* This version of the header files is NOT for user programs.
  32.  * It is intended for use when building the C runtimes ONLY.
  33.  * The version intended for public use will not have this message.
  34.  */
  35. #error ERROR: Use of C runtime library internal header file.
  36. #endif  /* _CRTBLD */
  37.  
  38. #ifndef _INTERNAL_IFSTRIP_
  39. #include <cruntime.h>
  40. #endif  /* _INTERNAL_IFSTRIP_ */
  41.  
  42.  
  43. /* Define _CRTIMP */
  44.  
  45. #ifndef _CRTIMP
  46. #ifdef CRTDLL
  47. #define _CRTIMP __declspec(dllexport)
  48. #else  /* CRTDLL */
  49. #ifdef _DLL
  50. #define _CRTIMP __declspec(dllimport)
  51. #else  /* _DLL */
  52. #define _CRTIMP
  53. #endif  /* _DLL */
  54. #endif  /* CRTDLL */
  55. #endif  /* _CRTIMP */
  56.  
  57.  
  58. /* Define __cdecl for non-Microsoft compilers */
  59.  
  60. #if (!defined (_MSC_VER) && !defined (__cdecl))
  61. #define __cdecl
  62. #endif  /* (!defined (_MSC_VER) && !defined (__cdecl)) */
  63.  
  64. /* Define _CRTAPI1 (for compatibility with the NT SDK) */
  65.  
  66. #ifndef _CRTAPI1
  67. #if _MSC_VER >= 800 && _M_IX86 >= 300
  68. #define _CRTAPI1 __cdecl
  69. #else  /* _MSC_VER >= 800 && _M_IX86 >= 300 */
  70. #define _CRTAPI1
  71. #endif  /* _MSC_VER >= 800 && _M_IX86 >= 300 */
  72. #endif  /* _CRTAPI1 */
  73.  
  74.  
  75. /* types and structures */
  76.  
  77. #ifndef _SIZE_T_DEFINED
  78. typedef unsigned int size_t;
  79. #define _SIZE_T_DEFINED
  80. #endif  /* _SIZE_T_DEFINED */
  81.  
  82. #ifdef _MSC_EXTENSIONS
  83. typedef void (__cdecl * new_handler) ();
  84. _CRTIMP new_handler __cdecl set_new_handler(new_handler);
  85. #endif  /* _MSC_EXTENSIONS */
  86.  
  87. #ifndef __PLACEMENT_NEW_INLINE
  88. #define __PLACEMENT_NEW_INLINE
  89. inline void *__cdecl operator new(size_t, void *_P)
  90.         {return (_P); }
  91. #if _MSC_VER >= 1200
  92. inline void __cdecl operator delete(void *, void *)
  93.         {return; }
  94. #endif  /* _MSC_VER >= 1200 */
  95. #endif  /* __PLACEMENT_NEW_INLINE */
  96.  
  97.  
  98. /*
  99.  * new mode flag -- when set, makes malloc() behave like new()
  100.  */
  101.  
  102. _CRTIMP int __cdecl _query_new_mode( void );
  103. _CRTIMP int __cdecl _set_new_mode( int );
  104.  
  105. #ifndef _PNH_DEFINED
  106. typedef int (__cdecl * _PNH)( size_t );
  107. #define _PNH_DEFINED
  108. #endif  /* _PNH_DEFINED */
  109.  
  110. _CRTIMP _PNH __cdecl _query_new_handler( void );
  111. _CRTIMP _PNH __cdecl _set_new_handler( _PNH );
  112.  
  113. /*
  114.  * Microsoft extension:
  115.  *
  116.  * _NO_ANSI_NEW_HANDLER de-activates the ANSI new_handler. Use this special value
  117.  * to support old style (_set_new_handler) behavior.
  118.  */
  119.  
  120. #ifndef _NO_ANSI_NH_DEFINED
  121. #define _NO_ANSI_NEW_HANDLER  ((new_handler)-1)
  122. #define _NO_ANSI_NH_DEFINED
  123. #endif  /* _NO_ANSI_NH_DEFINED */
  124.  
  125. #endif  /* __cplusplus */
  126.  
  127. #endif  /* _INC_NEW */
  128.