فهرست منبع

config: reintroduce ENTT_DISABLE_ASSERT (close #599)

Michele Caini 5 سال پیش
والد
کامیت
9356e8ccb5
2فایلهای تغییر یافته به همراه16 افزوده شده و 5 حذف شده
  1. 12 4
      docs/md/config.md
  2. 4 1
      src/entt/config/config.h

+ 12 - 4
docs/md/config.md

@@ -12,6 +12,7 @@
   * [ENTT_ID_TYPE](#entt_id_type)
   * [ENTT_ID_TYPE](#entt_id_type)
   * [ENTT_PAGE_SIZE](#entt_page_size)
   * [ENTT_PAGE_SIZE](#entt_page_size)
   * [ENTT_ASSERT](#entt_assert)
   * [ENTT_ASSERT](#entt_assert)
+    * [ENTT_DISABLE_ASSERT](#entt_disable_assert)
   * [ENTT_NO_ETO](#entt_no_eto)
   * [ENTT_NO_ETO](#entt_no_eto)
   * [ENTT_STANDARD_CPP](#entt_standard_cpp)
   * [ENTT_STANDARD_CPP](#entt_standard_cpp)
 
 
@@ -71,10 +72,17 @@ all case, the chosen value **must** be a power of 2.
 For performance reasons, `EnTT` doesn't use exceptions or any other control
 For performance reasons, `EnTT` doesn't use exceptions or any other control
 structures. In fact, it offers many features that result in undefined behavior
 structures. In fact, it offers many features that result in undefined behavior
 if not used correctly.<br/>
 if not used correctly.<br/>
-To get around this, the library relies on a lot of `assert`s for the purpose of
-detecting errors in debug builds. However, these assertions may in turn affect
-performance to an extent.<br/>
-This option is meant to disable all controls.
+To get around this, the library relies on a lot of asserts for the purpose of
+detecting errors in debug builds. By default, it uses `assert` internally, but
+users are allowed to overwrite its behavior by setting this variable.
+
+### ENTT_DISABLE_ASSERT
+
+Assertions may in turn affect performance to an extent when enabled. Whether
+`ENTT_ASSERT` is redefined or not, all asserts can be disabled at once by means
+of this definition.<br/>
+Note that `ENTT_DISABLE_ASSERT` takes precedence over the redefinition of
+`ENTT_ASSERT` and is therefore meant to disable all controls no matter what.
 
 
 ## ENTT_NO_ETO
 ## ENTT_NO_ETO
 
 

+ 4 - 1
src/entt/config/config.h

@@ -26,7 +26,10 @@
 #endif
 #endif
 
 
 
 
-#ifndef ENTT_ASSERT
+#ifdef ENTT_DISABLE_ASSERT
+#   undef ENTT_ASSERT
+#   define ENTT_ASSERT(...) (void(0))
+#elif !defined ENTT_ASSERT
 #   include <cassert>
 #   include <cassert>
 #   define ENTT_ASSERT(condition) assert(condition)
 #   define ENTT_ASSERT(condition) assert(condition)
 #endif
 #endif