STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
vcruntime.h
Go to the documentation of this file.
1 //
2 // vcruntime.h
3 //
4 // Copyright (c) Microsoft Corporation. All rights reserved.
5 //
6 // Declarations used throughout the VCRuntime library.
7 //
8 // Note on use of "deprecate":
9 //
10 // Various places in this header and other headers use
11 // __declspec(deprecate) or macros that have the term DEPRECATE in them.
12 // We use "deprecate" here ONLY to signal the compiler to emit a warning
13 // about these items. The use of "deprecate" should NOT be taken to imply
14 // that any standard committee has deprecated these functions from the
15 // relevant standards. In fact, these functions are NOT deprecated from
16 // the standard.
17 //
18 // Full details can be found in our documentation by searching for
19 // "Security Enhancements in the CRT".
20 //
21 #ifndef _UCRT
22  #define _UCRT
23 #endif
24 
25 // The _CRTIMP macro is not used in the VCRuntime or the CoreCRT anymore, but
26 // there is a lot of existing code that declares CRT functions using this macro,
27 // and if we remove its definition, we break that existing code. It is thus
28 // defined here only for compatibility.
29 #ifndef _CRTIMP
30  #define _VCRT_DEFINED_CRTIMP
31  #if defined CRTDLL && defined _CRTBLD
32  #define _CRTIMP __declspec(dllexport)
33  #else
34  #ifdef _DLL
35  #define _CRTIMP __declspec(dllimport)
36  #else
37  #define _CRTIMP
38  #endif
39  #endif
40 #endif
41 
42 #ifndef _VCRUNTIME_H
43 #define _VCRUNTIME_H
44 
45 #include <sal.h>
46 #include <vadefs.h>
47 
48 // All C headers have a common prologue and epilogue, to enclose the header in
49 // an extern "C" declaration when the header is #included in a C++ translation
50 // unit and to push/pop the packing.
51 #if defined __cplusplus
52 
53  #define _CRT_BEGIN_C_HEADER \
54  __pragma(pack(push, _CRT_PACKING)) \
55  extern "C" {
56 
57  #define _CRT_END_C_HEADER \
58  } \
59  __pragma(pack(pop))
60 
61 #elif defined __midl
62 
63  #define _CRT_BEGIN_C_HEADER \
64  cpp_quote("__pragma(pack(push, _CRT_PACKING))") \
65  cpp_quote("extern \"C\" {")
66 
67  #define _CRT_END_C_HEADER \
68  cpp_quote("}") \
69  cpp_quote("__pragma(pack(pop))")
70 
71 #else
72 
73  #define _CRT_BEGIN_C_HEADER \
74  __pragma(pack(push, _CRT_PACKING))
75 
76  #define _CRT_END_C_HEADER \
77  __pragma(pack(pop))
78 
79 #endif
80 
82 
83 
84 
85 #ifndef _HAS_EXCEPTIONS
86  #define _HAS_EXCEPTIONS 1 // Predefine as 0 to disable exceptions
87 #endif
88 
89 
90 
91 #define _CRT_STRINGIZE_(x) #x
92 #define _CRT_STRINGIZE(x) _CRT_STRINGIZE_(x)
93 
94 #define _CRT_WIDE_(s) L ## s
95 #define _CRT_WIDE(s) _CRT_WIDE_(s)
96 
97 #define _CRT_CONCATENATE_(a, b) a ## b
98 #define _CRT_CONCATENATE(a, b) _CRT_CONCATENATE_(a, b)
99 
100 #define _CRT_UNPARENTHESIZE_(...) __VA_ARGS__
101 #define _CRT_UNPARENTHESIZE(...) _CRT_UNPARENTHESIZE_ __VA_ARGS__
102 
103 
104 
105 #ifndef _VCRTIMP
106  #if defined _CRTIMP && !defined _VCRT_DEFINED_CRTIMP
107  #define _VCRTIMP _CRTIMP
108  #elif defined _VCRT_BUILD && defined CRTDLL
109  #define _VCRTIMP __declspec(dllexport)
110  #elif defined _CORECRT_BUILD
111  #define _VCRTIMP
112  #elif defined _DLL
113  #define _VCRTIMP __declspec(dllimport)
114  #else
115  #define _VCRTIMP
116  #endif
117 #endif
118 
119 #ifndef _MRTIMP
120  #if defined MRTDLL && defined _CRTBLD
121  #if !defined _M_CEE_PURE
122  #define _MRTIMP __declspec(dllexport)
123  #else
124  #define _MRTIMP
125  #endif
126  #else
127  #define _MRTIMP __declspec(dllimport)
128  #endif
129 #endif
130 
131 
132 
133 #ifdef _M_CEE_PURE
134  #define _VCRTIMP_PURE
135 #elif (defined _VCRT_BUILD || defined _CRTBLD) && defined MRTDLL
136  #define _VCRTIMP_PURE
137 #else
138  #define _VCRTIMP_PURE _VCRTIMP
139 #endif
140 
141 // Definitions of calling conventions used code sometimes compiled as managed
142 #if defined _M_CEE_PURE || defined MRTDLL
143  #define __CLRCALL_OR_CDECL __clrcall
144  #define __CLR_OR_THIS_CALL __clrcall
145 #else
146  #define __CLRCALL_OR_CDECL __cdecl
147  #define __CLR_OR_THIS_CALL
148 #endif
149 
150 #ifdef _M_CEE_PURE
151  #define __CLRCALL_PURE_OR_CDECL __clrcall
152 #else
153  #define __CLRCALL_PURE_OR_CDECL __cdecl
154 #endif
155 
156 #define __CRTDECL __CLRCALL_PURE_OR_CDECL
157 
158 // Definitions of common __declspecs
159 #define _VCRT_NOALIAS __declspec(noalias)
160 #define _VCRT_RESTRICT __declspec(restrict)
161 
162 #if !defined _MSC_VER || _MSC_VER >= 1900
163  #define _VCRT_ALLOCATOR __declspec(allocator)
164 #else
165  #define _VCRT_ALLOCATOR
166 #endif
167 
168 #if defined _M_CEE && defined _M_X64
169  #define _VCRT_JIT_INTRINSIC __declspec(jitintrinsic)
170 #else
171  #define _VCRT_JIT_INTRINSIC
172 #endif
173 
174 #ifdef __midl
175  #define _VCRT_ALIGN(x)
176 #else
177  #define _VCRT_ALIGN(x) __declspec(align(x))
178 #endif
179 
180 #ifndef _CONST_RETURN
181  #ifdef __cplusplus
182  #define _CRT_CONST_CORRECT_OVERLOADS
183  #define _CONST_RETURN const
184  #else
185  #define _CONST_RETURN
186  #endif
187 #endif
188 
189 // For backwards compatibility
190 #define _WConst_return _CONST_RETURN
191 
192 // Definitions of common types
193 #ifdef _WIN64
194  typedef unsigned __int64 size_t;
195  typedef __int64 ptrdiff_t;
196  typedef __int64 intptr_t;
197 #else
198  typedef unsigned int size_t;
199  typedef int ptrdiff_t;
200  typedef int intptr_t;
201 #endif
202 
203 #if defined __cplusplus
204  typedef bool __vcrt_bool;
205 #elif defined __midl
206  // MIDL understands neither bool nor _Bool. Use char as a best-fit
207  // replacement (the differences won't matter in practice).
208  typedef char __vcrt_bool;
209 #else
210  typedef _Bool __vcrt_bool;
211 #endif
212 
213 // Indicate that these common types are defined
214 #ifndef _SIZE_T_DEFINED
215  #define _SIZE_T_DEFINED
216 #endif
217 
218 #ifndef _PTRDIFF_T_DEFINED
219  #define _PTRDIFF_T_DEFINED
220 #endif
221 
222 #ifndef _INTPTR_T_DEFINED
223  #define _INTPTR_T_DEFINED
224 #endif
225 
226 // Provide a typedef for wchar_t for use under /Zc:wchar_t-
227 #ifndef _WCHAR_T_DEFINED
228  #define _WCHAR_T_DEFINED
229  typedef unsigned short wchar_t;
230 #endif
231 
232 #ifndef NULL
233  #ifdef __cplusplus
234  #define NULL 0
235  #else
236  #define NULL ((void *)0)
237  #endif
238 #endif
239 
240 #if defined _M_X64 || defined _M_ARM || defined _M_ARM64
241  #define _UNALIGNED __unaligned
242 #else
243  #define _UNALIGNED
244 #endif
245 
246 #ifdef __cplusplus
247  extern "C++"
248  {
249  template <typename _CountofType, size_t _SizeOfArray>
250  char (*__countof_helper(_UNALIGNED _CountofType (&_Array)[_SizeOfArray]))[_SizeOfArray];
251 
252  #define __crt_countof(_Array) (sizeof(*__countof_helper(_Array)) + 0)
253  }
254 #else
255  #define __crt_countof(_Array) (sizeof(_Array) / sizeof(_Array[0]))
256 #endif
257 
258 // See note on use of "deprecate" at the top of this file
259 #define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text))
260 
261 #if defined _CRT_SECURE_NO_DEPRECATE && !defined _CRT_SECURE_NO_WARNINGS
262  #define _CRT_SECURE_NO_WARNINGS
263 #endif
264 
265 #ifndef _CRT_INSECURE_DEPRECATE
266  #ifdef _CRT_SECURE_NO_WARNINGS
267  #define _CRT_INSECURE_DEPRECATE(_Replacement)
268  #else
269  #define _CRT_INSECURE_DEPRECATE(_Replacement) _CRT_DEPRECATE_TEXT( \
270  "This function or variable may be unsafe. Consider using " \
271  #_Replacement \
272  " instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. " \
273  "See online help for details.")
274  #endif
275 #endif
276 
277 #if defined _CRT_SECURE_DEPRECATE_MEMORY && !defined _CRT_SECURE_WARNINGS_MEMORY
278  #define _CRT_SECURE_WARNINGS_MEMORY
279 #endif
280 
281 #ifndef _CRT_INSECURE_DEPRECATE_MEMORY
282  #ifndef _CRT_SECURE_WARNINGS_MEMORY
283  #define _CRT_INSECURE_DEPRECATE_MEMORY(_Replacement)
284  #else
285  #define _CRT_INSECURE_DEPRECATE_MEMORY(_Replacement) \
286  _CRT_INSECURE_DEPRECATE(_Replacement)
287  #endif
288 #endif
289 
290 
291 
292 #define _CRT_WARNING(description) \
293  message("" __FILE__ "(" _CRT_STRINGIZE(__LINE__) ") : warning CRT0000 : " _CRT_STRINGIZE(description))
294 
295 
296 
297 #if !defined _M_CEE && !defined __midl
298  void __cdecl __security_init_cookie(void);
299 
300  #ifdef _M_IX86
301  void __fastcall __security_check_cookie(_In_ uintptr_t _StackCookie);
302  __declspec(noreturn) void __cdecl __report_gsfailure(void);
303  #else /* _M_IX86 */
304  void __cdecl __security_check_cookie(_In_ uintptr_t _StackCookie);
305  __declspec(noreturn) void __cdecl __report_gsfailure(_In_ uintptr_t _StackCookie);
306  #endif
307 #endif
308 
310 
311 #ifndef _VCRT_BUILD
312  #define __vcrt_malloc_normal(_Size) malloc(_Size)
313  #define __vcrt_calloc_normal(_Count, _Size) calloc(_Count, _Size)
314  #define __vcrt_free_normal(_Memory) free(_Memory)
315 #endif
316 
318 
319 #endif // _VCRUNTIME_H
_Bool __vcrt_bool
Definition: vcruntime.h:210
uintptr_t __security_cookie
#define _UNALIGNED
Definition: vcruntime.h:243
__declspec(noreturn) void __cdecl __report_gsfailure(_In_ uintptr_t _StackCookie)
Cancels the currently executing task. This function can be called from within the body of a task to a...
Definition: ppltasks.h:131
void __cdecl __security_check_cookie(_In_ uintptr_t _StackCookie)
#define _CRT_BEGIN_C_HEADER
Definition: vcruntime.h:73
int ptrdiff_t
Definition: vcruntime.h:199
unsigned int uintptr_t
Definition: vadefs.h:30
#define _In_
Definition: sal.h:305
unsigned int size_t
Definition: vcruntime.h:198
int intptr_t
Definition: vcruntime.h:200
unsigned short wchar_t
Definition: vcruntime.h:229
#define _CRT_END_C_HEADER
Definition: vcruntime.h:76
_CRT_BEGIN_C_HEADER typedef void(__CRTDECL *unexpected_handler)()
void __cdecl __security_init_cookie(void)