pal_assert.h 908 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //
  2. // Copyright (c) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
  4. //
  5. /*++
  6. --*/
  7. #ifndef __PAL_ASSERT_H__
  8. #define __PAL_ASSERT_H__
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. #ifdef __cplusplus
  13. //
  14. // C_ASSERT() can be used to perform many compile-time assertions:
  15. // type sizes, field offsets, etc.
  16. //
  17. #define C_ASSERT(e) static_assert(e, #e)
  18. //
  19. // CPP_ASSERT() can be used within a class definition, to perform a
  20. // compile-time assertion involving private names within the class.
  21. //
  22. #define CPP_ASSERT(n, e) static_assert(e, #e)
  23. #endif // __cplusplus
  24. #if defined(_DEBUG)
  25. #include "assert_only.h"
  26. #define _ASSERTE(e) Assert(e)
  27. #else // !DEBUG
  28. #define _ASSERTE(e) ((void)0)
  29. #endif
  30. #ifndef assert
  31. #define assert(e) _ASSERTE(e)
  32. #endif // assert
  33. #ifdef __cplusplus
  34. }
  35. #endif
  36. #endif // __PAL_ASSERT_H__