zf_assert.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. *****************************************************************************
  3. * @file zf_assert.h
  4. * @author Zorb
  5. * @version V1.0.0
  6. * @date 2018-06-28
  7. * @brief 断言的头文件
  8. *****************************************************************************
  9. * @history
  10. *
  11. * 1. Date:2018-06-28
  12. * Author:Zorb
  13. * Modification:建立文件
  14. *
  15. *****************************************************************************
  16. */
  17. #ifndef __ZF_ASSERT_H__
  18. #define __ZF_ASSERT_H__
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. #include "stdint.h"
  23. #define _ZF_ASSERT /* 定义断言功能 */
  24. #define ZF_ASSERT_ON true /* 启用断言功能 */
  25. #ifdef _ZF_ASSERT
  26. #if ZF_ASSERT_ON
  27. #define ZF_ASSERT(expression_) ((expression_) ?\
  28. (void)0 : ZF_assertHandle((uint8_t *)__FILE__, (int)__LINE__));
  29. #else
  30. #define ZF_ASSERT(expression_)
  31. #endif /* ZF_ASSERT_ON */
  32. #endif /* _ZF_ASSERT */
  33. /* 断言产生时的处理 */
  34. void ZF_assertHandle(uint8_t *pFileName, int line);
  35. #ifdef __cplusplus
  36. }
  37. #endif
  38. #endif /* __ZF_ASSERT_H__ */
  39. /******************************** END OF FILE ********************************/