YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
cassert.cpp
浏览该文件的文档.
1 /*
2  © 2013-2014 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 #include "ystdex/cassert.h"
29 #include <exception> // for std::terminate;
30 #include <cstdarg>
31 
32 namespace ystdex
33 {
34 
35 #ifdef YB_Use_YAssert
36 void
37 yassert(bool expr, const char* expr_str, const char* file, int line,
38  const char* msg)
39 {
40  if(YB_UNLIKELY(!expr))
41  {
42  std::fprintf(stderr, "Assertion failed @ \"%s\":%i:\n"
43  " %s .\nMessage: \n%s\n", file, line, expr_str, msg);
45  }
46 }
47 #endif
48 
49 #if YB_Use_YTrace
50 void
51 ytrace(std::FILE* stream, std::uint8_t lv, std::uint8_t t, const char* file,
52  int line, const char* msg, ...)
53 {
54  if(lv < t)
55  {
56  std::fprintf(stream, "Trace[%#X] @ \"%s\":%i:\n", unsigned(lv), file,
57  line);
58 
59  std::va_list args;
60  va_start(args, msg);
61  std::vfprintf(stream, msg, args);
62  va_end(args);
63  }
64 }
65 #endif
66 
67 } // namespace ystdex;
68 
yconstfn const string _tParams && args
Definition: Loader.h:111
ISO C 断言/调试跟踪扩展。
void ytrace(std::FILE *, std::uint8_t, std::uint8_t, const char *, int, const char *,...)
YCLib 调试跟踪函数。
YB_NORETURN YF_API void terminate() ynothrow
异常终止函数。
Definition: ycommon.cpp:39
#define YB_UNLIKELY(expr)
分支预测提示。
Definition: ydef.h:298
void yassert(bool, const char *, const char *, int, const char *)
YBase 默认断言函数。