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

Compile-time check for correct padding and alignment in ImVec2

This commit is contained in:
Brayden Lee 2025-12-23 15:08:00 -05:00
parent 4707b7e732
commit 4b022e571c

View file

@ -76,7 +76,7 @@ Index of this file:
// Includes
#include <float.h> // FLT_MIN, FLT_MAX
#include <stdarg.h> // va_list, va_start, va_end
#include <stddef.h> // ptrdiff_t, NULL
#include <stddef.h> // ptrdiff_t, NULL, offsetof
#include <string.h> // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp
// Define attributes of all API symbols declarations (e.g. for DLL under Windows)
@ -303,6 +303,8 @@ 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.
#endif
};
static_assert(offsetof(ImVec2, y) - offsetof(ImVec2, x) == sizeof(float), "Cannot compile ImVec2 due to an alignment/padding violation.\
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]
struct ImVec4