You.i Engine
YiError.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2017. All rights reserved.
2 #ifndef _YI_ERROR_H_
3 #define _YI_ERROR_H_
4 
5 #include <cassert>
6 
8 
14 #define YI_ERROR_NONE 0
15 
16 // These should be in their respective files, not here!
17 #define YI_ERROR_NOTSUPPORT_BITDEPTH -10
18 #define YI_ERROR_NOTSUPPORT_SCREENACCESS -20
19 #define YI_ERROR_NOTSUPPORT_INPUTACCESS -30
20 #define YI_ERROR_DISPLAY_BUFFER_CREATION -40
21 
22 #if !defined(YI_DEBUG) || defined(DOXY)
23 
31  // For performance reasons on release builds we do not want condition to execute. One may wish
32  // to evaluate a function in the assert. To avoid the function executing in a release
33  // build, we use sizeof. This is a compile time operation and will insert the size
34  // of the return value of the function at compile time rather than allowing the
35  // function to evaluate at run time.
36 
37  #define YI_ASSERT(condition, tag, msg, ...) \
38  YI_REMOVE_CONSTANT_CONDITION(YI_UNUSED(sizeof(condition)); YI_UNUSED(tag);)
39 #elif defined(__clang_analyzer__)
40  #define YI_ASSERT(condition, tag, msg, ...) \
41  do \
42  { \
43  if (!(condition)) \
44  { \
45  YI_LOGE(tag, "%s: " msg, "Assertion failed", ##__VA_ARGS__); \
46  } \
47  } while ((void)0, 0)
48 #elif defined(YI_WIN32)
49  #define YI_ASSERT(condition, tag, msg, ...) \
50  __pragma(warning(push)) \
51  __pragma(warning(disable:4127)) \
52  do \
53  { \
54  if (!(condition)) \
55  { \
56  YI_LOGF(tag, "%s: " msg, "Assertion failed", ##__VA_ARGS__); \
57  } \
58  } \
59  while ((void)0, 0) \
60  __pragma(warning(pop))
61 #else
62  #define YI_ASSERT(condition, tag, msg, ...) \
63  do \
64  { \
65  if (!(condition)) \
66  { \
67  YI_LOGF(tag, "Assertion failed: " msg, ##__VA_ARGS__); \
68  } \
69  } \
70  while ((void)0, 0)
71 #endif
72 
75 #endif //# _YI_ERROR_H_
76