1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-09 23:54:20 +00:00

Config/build infos emit infos to convey when IM_ASSERT() macro is disabled.

This commit is contained in:
ocornut 2025-10-30 18:03:36 +01:00
parent 670a92723a
commit 149587b85b
4 changed files with 25 additions and 1 deletions

View file

@ -8185,6 +8185,25 @@ void ImGui::ShowAboutWindow(bool* p_open)
ImGui::Text("define: __EMSCRIPTEN__");
ImGui::Text("Emscripten: %d.%d.%d", __EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__);
#endif
#ifdef NDEBUG
ImGui::Text("define: NDEBUG");
#endif
// Heuristic to detect no-op IM_ASSERT() macros
// - This is designed so people opening bug reports would convey and notice that they have disabled asserts for Dear ImGui code.
// - 16 is > strlen("((void)(_EXPR))") which we suggested in our imconfig.h template as a possible way to disable.
int assert_runs_expression = 0;
IM_ASSERT(++assert_runs_expression);
int assert_expand_len = (int)strlen(IM_STRINGIFY(IM_ASSERT(true)));
bool assert_maybe_disabled = (!assert_runs_expression || assert_expand_len <= 16);
ImGui::Text("IM_ASSERT: runs expression: %s. expand size: %s%s",
assert_runs_expression ? "OK" : "KO", (assert_expand_len > 16) ? "OK" : "KO", assert_maybe_disabled ? " (MAYBE DISABLED?!)" : "");
if (assert_maybe_disabled)
{
ImGui::SameLine();
HelpMarker("IM_ASSERT() calls assert() by default. Compiling with NDEBUG will usually strip out assert() to nothing, which is NOT recommended because we use asserts to notify of programmer mistakes!");
}
ImGui::Separator();
ImGui::Text("io.BackendPlatformName: %s", io.BackendPlatformName ? io.BackendPlatformName : "NULL");
ImGui::Text("io.BackendRendererName: %s", io.BackendRendererName ? io.BackendRendererName : "NULL");