Fixed a bug in the CLAY macro that would cause an infinite loop if 256 for loops ended at the same time (i.e. without another for loop starting). This was caused by the CLAY__ELEMENT_DEFINITION_LATCH static uint8_t overflowing to 0 when incremented in the post-loop step which causes the loop to wrongfully run a second time

This commit is contained in:
Taylor Robbins (Piggybank Studios) 2025-03-24 18:21:24 -07:00
parent 5009146c65
commit 08d4a22121

2
clay.h
View File

@ -132,7 +132,7 @@ static uint8_t CLAY__ELEMENT_DEFINITION_LATCH;
for ( \
CLAY__ELEMENT_DEFINITION_LATCH = (Clay__OpenElement(), Clay__ConfigureOpenElement(CLAY__CONFIG_WRAPPER(Clay_ElementDeclaration, __VA_ARGS__)), 0); \
CLAY__ELEMENT_DEFINITION_LATCH < 1; \
++CLAY__ELEMENT_DEFINITION_LATCH, Clay__CloseElement() \
CLAY__ELEMENT_DEFINITION_LATCH=1, Clay__CloseElement() \
)
// These macros exist to allow the CLAY() macro to be called both with an inline struct definition, such as