1 /** 2 * This file has no copyright assigned and is placed in the Public Domain. 3 * This file is part of the mingw-w64 runtime package. 4 * No warranty is given; refer to the file DISCLAIMER.PD within this package. 5 */ 6 7 /* According to C99 standard (section 7.2) the assert 8 macro shall be redefined each time assert.h gets 9 included depending on the status of NDEBUG macro. */ 10 #undef assert 11 12 #ifndef __ASSERT_H_ 13 #define __ASSERT_H_ 14 15 #include <crtdefs.h> 16 #ifdef __cplusplus 17 #include <stdlib.h> 18 #endif 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 #ifndef _CRT_TERMINATE_DEFINED 25 #define _CRT_TERMINATE_DEFINED 26 void __cdecl __MINGW_NOTHROW exit(int _Code) __MINGW_ATTRIB_NORETURN; 27 void __cdecl __MINGW_NOTHROW _exit(int _Code) __MINGW_ATTRIB_NORETURN; 28 29 #if !defined __NO_ISOCEXT /* extern stub in static libmingwex.a */ 30 /* C99 function name */ 31 void __cdecl _Exit(int) __MINGW_ATTRIB_NORETURN; 32 #ifndef __CRT__NO_INLINE 33 __CRT_INLINE __MINGW_ATTRIB_NORETURN void __cdecl _Exit(int status) 34 { _exit(status); } 35 #endif /* !__CRT__NO_INLINE */ 36 #endif /* Not __NO_ISOCEXT */ 37 38 #pragma push_macro("abort") 39 #undef abort 40 void __cdecl __declspec(noreturn) abort(void); 41 #pragma pop_macro("abort") 42 43 #endif /* _CRT_TERMINATE_DEFINED */ 44 45 extern void __cdecl 46 _wassert(const wchar_t *_Message,const wchar_t *_File,unsigned _Line); 47 extern void __cdecl 48 _assert (const char *_Message, const char *_File, unsigned _Line); 49 50 #ifdef __cplusplus 51 } 52 #endif 53 54 #endif /* !defined (__ASSERT_H_) */ 55 56 #if (defined _ISOC11_SOURCE \ 57 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L)) \ 58 && !defined (__cplusplus) 59 /* Static assertion. Requires support in the compiler. */ 60 #undef static_assert 61 #define static_assert _Static_assert 62 #endif 63 64 #ifdef NDEBUG 65 #define assert(_Expression) ((void)0) 66 #else /* !defined (NDEBUG) */ 67 #if defined(_UNICODE) || defined(UNICODE) 68 #define assert(_Expression) \ 69 (void) \ 70 ((!!(_Expression)) || \ 71 (_wassert(_CRT_WIDE(#_Expression),_CRT_WIDE(__FILE__),__LINE__),0)) 72 #else /* not unicode */ 73 #define assert(_Expression) \ 74 (void) \ 75 ((!!(_Expression)) || \ 76 (_assert(#_Expression,__FILE__,__LINE__),0)) 77 #endif /* _UNICODE||UNICODE */ 78 #endif /* !defined (NDEBUG) */ 79 80