mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-09 23:54:20 +00:00
Factor out error message to IM_PADDING_CHECK_FAIL_MSG and check the padding on ImVec4
This commit is contained in:
parent
4b022e571c
commit
60a6c7be98
1 changed files with 8 additions and 2 deletions
10
imgui.h
10
imgui.h
|
|
@ -152,6 +152,10 @@ Index of this file:
|
||||||
#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
|
#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define IM_PADDING_CHECK_FAIL_MSG(TypeName) "Cannot compile "## #TypeName ##" due to an padding assumption violation. \
|
||||||
|
Please reply to (or start) the issue with your compiler version and flags at https://github.com/ocornut/imgui/issues."
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Forward declarations and basic types
|
// [SECTION] Forward declarations and basic types
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -303,8 +307,7 @@ struct ImVec2
|
||||||
IM_VEC2_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec2.
|
IM_VEC2_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec2.
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
static_assert(offsetof(ImVec2, y) - offsetof(ImVec2, x) == sizeof(float), "Cannot compile ImVec2 due to an alignment/padding violation.\
|
static_assert(offsetof(ImVec2, y) - offsetof(ImVec2, x) == sizeof(float), IM_PADDING_CHECK_FAIL_MSG(ImVec2));
|
||||||
Please reply to (or start) the issue with your compiler version and flags at https://github.com/ocornut/imgui/issues.");
|
|
||||||
|
|
||||||
// ImVec4: 4D vector used to store clipping rectangles, colors etc. [Compile-time configurable type]
|
// ImVec4: 4D vector used to store clipping rectangles, colors etc. [Compile-time configurable type]
|
||||||
struct ImVec4
|
struct ImVec4
|
||||||
|
|
@ -316,6 +319,9 @@ struct ImVec4
|
||||||
IM_VEC4_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec4.
|
IM_VEC4_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec4.
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
// It is guaranteed that struct fields are in order of declaration, i.e. addressof(x) < addressof(y) < addressof(z) < addressof(w)
|
||||||
|
// This check uses the guarantee to ensure our padding assumption is correct for all members with only one comparison (concise, less error-prone).
|
||||||
|
static_assert(offsetof(ImVec4, w) - offsetof(ImVec4, x) == 3 * sizeof(float), IM_PADDING_CHECK_FAIL_MSG(ImVec4));
|
||||||
IM_MSVC_RUNTIME_CHECKS_RESTORE
|
IM_MSVC_RUNTIME_CHECKS_RESTORE
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue