mirror of
https://github.com/ocornut/imgui.git
synced 2025-12-18 12:25:36 +00:00
Config/build infos emit infos to convey when IM_ASSERT() macro is disabled.
This commit is contained in:
@@ -67,6 +67,9 @@ Other Changes:
|
|||||||
triggered by some widgets e.g. Checkbox(), Selectable() and many others, which
|
triggered by some widgets e.g. Checkbox(), Selectable() and many others, which
|
||||||
cleared ActiveId at the same time as editing. (#9028)
|
cleared ActiveId at the same time as editing. (#9028)
|
||||||
Note that IsItemDeactivatedAfterEdit() was not affected, only IsItemEdited).
|
Note that IsItemDeactivatedAfterEdit() was not affected, only IsItemEdited).
|
||||||
|
- Demo: About Box: emit infos to convey when IM_ASSERT() macro is disabled,
|
||||||
|
- so users don't miss out on programming errors being reported.
|
||||||
|
- so it is included in config/build info submitted in new GitHub Issues.
|
||||||
- Debug Tools: fixed DebugTextEncoding() potentially reading out of bounds
|
- Debug Tools: fixed DebugTextEncoding() potentially reading out of bounds
|
||||||
if provided a trailing truncated UTF-8 sequence.
|
if provided a trailing truncated UTF-8 sequence.
|
||||||
- Backends:
|
- Backends:
|
||||||
|
|||||||
@@ -15,7 +15,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
//---- Define assertion handler. Defaults to calling assert().
|
//---- Define assertion handler. Defaults to calling assert().
|
||||||
// If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement.
|
// - If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement.
|
||||||
|
// - Compiling with NDEBUG will usually strip out assert() to nothing, which is NOT recommended because we use asserts to notify of programmer mistakes.
|
||||||
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
|
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
|
||||||
//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
|
//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
|
||||||
|
|
||||||
|
|||||||
1
imgui.h
1
imgui.h
@@ -89,6 +89,7 @@ Index of this file:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Helper Macros
|
// Helper Macros
|
||||||
|
// (note: compiling with NDEBUG will usually strip out assert() to nothing, which is NOT recommended because we use asserts to notify of programmer mistakes.)
|
||||||
#ifndef IM_ASSERT
|
#ifndef IM_ASSERT
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#define IM_ASSERT(_EXPR) assert(_EXPR) // You can override the default assert handler by editing imconfig.h
|
#define IM_ASSERT(_EXPR) assert(_EXPR) // You can override the default assert handler by editing imconfig.h
|
||||||
|
|||||||
@@ -8185,6 +8185,25 @@ void ImGui::ShowAboutWindow(bool* p_open)
|
|||||||
ImGui::Text("define: __EMSCRIPTEN__");
|
ImGui::Text("define: __EMSCRIPTEN__");
|
||||||
ImGui::Text("Emscripten: %d.%d.%d", __EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__);
|
ImGui::Text("Emscripten: %d.%d.%d", __EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__);
|
||||||
#endif
|
#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::Separator();
|
||||||
ImGui::Text("io.BackendPlatformName: %s", io.BackendPlatformName ? io.BackendPlatformName : "NULL");
|
ImGui::Text("io.BackendPlatformName: %s", io.BackendPlatformName ? io.BackendPlatformName : "NULL");
|
||||||
ImGui::Text("io.BackendRendererName: %s", io.BackendRendererName ? io.BackendRendererName : "NULL");
|
ImGui::Text("io.BackendRendererName: %s", io.BackendRendererName ? io.BackendRendererName : "NULL");
|
||||||
|
|||||||
Reference in New Issue
Block a user