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 _Exit(int status)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 __MINGW_ATTRIB_NORETURN abort(void); 41 #pragma pop_macro("abort") 42 43 #endif /* _CRT_TERMINATE_DEFINED */ 44 45 _CRTIMP void __cdecl _wassert(const wchar_t *_Message,const wchar_t *_File,unsigned _Line); 46 _CRTIMP void __cdecl _assert (const char *_Message, const char *_File, unsigned _Line); 47 48 #ifdef __cplusplus 49 } 50 #endif 51 52 #endif /* !defined (__ASSERT_H_) */ 53 54 #if (defined _ISOC11_SOURCE \ 55 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L)) \ 56 && !defined (__cplusplus) 57 /* Static assertion. Requires support in the compiler. */ 58 #undef static_assert 59 #define static_assert _Static_assert 60 #endif 61 62 #ifdef NDEBUG 63 #define assert(_Expression) ((void)0) 64 #else /* !defined (NDEBUG) */ 65 #if defined(_UNICODE) || defined(UNICODE) 66 #define assert(_Expression) \ 67 (void) \ 68 ((!!(_Expression)) || \ 69 (_wassert(_CRT_WIDE(#_Expression),_CRT_WIDE(__FILE__),__LINE__),0)) 70 #else /* not unicode */ 71 #define assert(_Expression) \ 72 (void) \ 73 ((!!(_Expression)) || \ 74 (_assert(#_Expression,__FILE__,__LINE__),0)) 75 #endif /* _UNICODE||UNICODE */ 76 #endif /* !defined (NDEBUG) */ 77 78