YSTest: cassert.h 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

cassert.h
浏览该文件的文档.
1 /*
2 © 2012-2015 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef YB_INC_ystdex_cassert_h_
29 #define YB_INC_ystdex_cassert_h_ 1
30
31 #include "../ydef.h"
32 #include <cstdio>
33
34 namespace ystdex
35 {
36
45 YB_NORETURN YB_API void
46 yassert(const char*, const char*, int, const char*) ynothrow;
47
48 #if YB_Use_YTrace
49
54 YB_API YB_ATTR_gnu_printf(6, 7) void
55 ytrace(std::FILE*, std::uint8_t, std::uint8_t, const char*, int, const char*,
56 ...) ynothrow;
57 #endif
58
59 } // namespace ystdex;
60
61 #endif // NOTE: Allow multiple for macro definitions.
62
63 #include <cassert>
64
65 #undef yconstraint
66 #undef yassume
67
79 #ifdef NDEBUG
80 # define yconstraint(_expr) YB_ASSUME(_expr)
81 #else
82 # define yconstraint(_expr) \
83 ((_expr) ? void(0) : ystdex::yassert(#_expr, __FILE__, __LINE__, \
84 "Constraint violation."))
85 #endif
86
96 #ifdef NDEBUG
97 # define yassume(_expr) YB_ASSUME(_expr)
98 #else
99 # define yassume(_expr) assert(_expr)
100 #endif
101
102
103 #ifndef YAssert
104 # if YB_Use_YAssert
105 # define YAssert(_expr, _msg) \
106 ((_expr) ? void(0) : ystdex::yassert(#_expr, __FILE__, __LINE__, _msg))
107 # else
108 # define YAssert(_expr, _msg) yassume(_expr)
109 # endif
110 #endif
111
112 #ifndef YAssertNonnull
113 # define YAssertNonnull(_expr) YAssert(bool(_expr), "Null reference found.")
115 #endif
116
117 #ifndef YTrace
118
120
125 # if YB_Use_YTrace
126 # define YTrace(_stream, _lv, _t, _msg, ...) \
127 ystdex::ytrace(_stream, _lv, _t, __FILE__, __LINE__, _msg, __VA_ARGS__)
128 # else
129 # define YTrace(...)
130 # endif
131 #endif
132
133
YB_NORETURN
#define YB_NORETURN
指定无返回值函数。
Definition: ydef.h:478
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:740
ystdex::ytrace
void ytrace(std::FILE *, std::uint8_t, std::uint8_t, const char *, int, const char *,...)
YCLib 调试跟踪函数。
ystdex::yassert
void yassert(const char *, const char *, int, const char *)
YBase 默认断言函数。
Definition: cassert.cpp:36
YB_API
#define YB_API
YBase 应用程序编程接口：用于向库文件约定链接。
Definition: ydef.h:566
std
Definition: memory.hpp:1100
ystdex
特性测试宏。
Definition: ydef.h:796
YB_ATTR_gnu_printf
#define YB_ATTR_gnu_printf(...)
GNU 风格 printf 属性。
Definition: ydef.h:375