assert.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * This file has no copyright assigned and is placed in the Public Domain.
  3. * This file is part of the w64 mingw-runtime package.
  4. * No warranty is given; refer to the file DISCLAIMER within this package.
  5. */
  6. #ifndef __ASSERT_H_
  7. #define __ASSERT_H_
  8. #include <_mingw.h>
  9. #ifdef __cplusplus
  10. #include <stdlib.h>
  11. #endif
  12. #ifdef NDEBUG
  13. #ifndef assert
  14. #define assert(_Expression) ((void)0)
  15. #endif
  16. #else
  17. #ifndef _CRT_TERMINATE_DEFINED
  18. #define _CRT_TERMINATE_DEFINED
  19. void __cdecl __MINGW_NOTHROW exit(int _Code) __MINGW_ATTRIB_NORETURN;
  20. _CRTIMP void __cdecl __MINGW_NOTHROW _exit(int _Code) __MINGW_ATTRIB_NORETURN;
  21. #if !defined __NO_ISOCEXT /* extern stub in static libmingwex.a */
  22. /* C99 function name */
  23. void __cdecl _Exit(int) __MINGW_ATTRIB_NORETURN;
  24. __CRT_INLINE __MINGW_ATTRIB_NORETURN void __cdecl _Exit(int status)
  25. { _exit(status); }
  26. #endif
  27. #pragma push_macro("abort")
  28. #undef abort
  29. void __cdecl __declspec(noreturn) abort(void);
  30. #pragma pop_macro("abort")
  31. #endif
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. extern void __cdecl _wassert(const wchar_t *_Message,const wchar_t *_File,unsigned _Line);
  36. extern void __cdecl _assert(const char *, const char *, unsigned);
  37. #ifdef __cplusplus
  38. }
  39. #endif
  40. #ifndef assert
  41. //#define assert(_Expression) (void)((!!(_Expression)) || (_wassert(_CRT_WIDE(#_Expression),_CRT_WIDE(__FILE__),__LINE__),0))
  42. #define assert(e) ((e) ? (void)0 : _assert(#e, __FILE__, __LINE__))
  43. #endif
  44. #endif
  45. #if (__STDC_VERSION__ >= 201112L) && !defined(static_assert)
  46. /* C11, section 7.2: The macro static_assert expands to _Static_assert. */
  47. #define static_assert(exp, str) _Static_assert(exp, str)
  48. #endif
  49. #endif