Repository navigation
Troubleshooting
Find a build error or runtime symptom below and apply the listed fix.
Link your target to ccompose or ccompose_headless so it includes the implementation. Including ccompose.h alone does not define the functions.
Headless builds (-DCCOMPOSE_BACKEND_RAYLIB=OFF) exclude raylib.h from the include path. Remove raylib includes and calls from headless source files, or guard that code with #ifndef CCOMPOSE_NO_BACKEND.
ccompose prints Clay errors to stderr unless you set a handler with CC_SetErrorHandler. These errors identify common layout problems:
Clay has more open elements than close calls. Check the control flow inside container blocks:
break inside a container block.
Column("X") {
if (fail) break; // Incorrect: skips CC_CloseScope
Text("ok", ...);
}Use continue instead (it runs the for-loop's step clause, closing the element cleanly):
Column("X") {
if (fail) continue; // Runs the close step
Text("ok", ...);
}return also skips the loop's close step, even inside a helper function:
static void build_maybe(bool fail) {
Column("X") {
if (fail) return; // Incorrect: skips CC_CloseScope
Text("ok", ...);
}
}Let the container block finish before returning from the helper.
A goto that leaves the block also skips its close step.
Container macro used as the unbraced body of an if.
if (show_sidebar) Column("Sidebar") { ... } // Incorrect: scoping weirdnessWrap in braces:
if (show_sidebar) {
Column("Sidebar") { ... }
}You reused the same id (ids hash by content, so this also happens with snprintf'd strings that produce the same bytes) for two different elements in the same frame. Clay requires ids to be globally unique per layout.
// Both boxes use the same id in one frame.
Row("Toolbar") {
Box("Spacer", .layout = { .sizing = { Grow(), Fit() } });
}
Column("PrayerCard") {
Box("Spacer", .layout = { .sizing = { Fit(), Grow() } });
}Use an anonymous leaf for layout filler:
Row("Toolbar") { HSpacer(); }
Column("PrayerCard") { VSpacer(); }See Spacer and divider. For repeated named elements, format a unique id with snprintf:
for (int i = 0; i < count; ++i) {
char id[24];
snprintf(id, sizeof id, "row-%d", i);
Row(id, .layout = { ... }) { /* ... */ }
}Or use CC_IDI("row", i) + raw CLAY({ ... }) blocks if you want index-offset hashing without the format string.
Clay's element pool is full. Raise the cap after CC_Init():
CC_Init();
Clay_SetMaxElementCount(16384); // default is ~8192The new limit takes effect on the next CC_Begin.
Clay's text-measure cache is full. Raise that cap similarly:
CC_Init();
Clay_SetMaxMeasureTextCacheWordCount(32768);A floating element set .floating.attachTo = CC_ATTACH_TO_ELEMENT_WITH_ID with a .parentId that doesn't match any element in the current frame. Make sure:
- The anchor element with that id is declared earlier in the layout.
- You're passing
CLAY_ID("name").id(the hasheduint32_t), not the raw string"name".
Clay tests the pointer against the previous frame's layout. On the first frame an element appears, CC_Hovered and CC_Clicked return false. For detection in the frame when you move an element, test pointer coordinates against its rectangle yourself.
CC__MousePressedThisFrame() always returns false in headless mode. See Pointer input in tests for simulated pointer and press handling.
Clay doesn't clip by default. Set .clip = { .horizontal = true, .vertical = true } on the parent if you want overflow hidden. See Scroll and clip.
Two possible causes:
- The parent has
Fit()sizing on the wrap axis.Fit()shrink-wraps around children: there's no bound for text to wrap against. Switch the parent toGrow()orFixed(px). -
.wrapMode = CC_TEXT_WRAP_NONEwas explicitly set. Default isCC_TEXT_WRAP_WORDS.
-
Call
CC_LoadFont()afterCC_Init()so raylib has a GL context. -
Check the returned id. A value of
-1means loading failed. Fall back to slot0if needed:int FONT_UI = CC_LoadFont("resources/Inter.ttf", 16); if (FONT_UI < 0) FONT_UI = 0;
-
Pass the returned id as
.fontId, or select it withCC_InitFont. A.fontIdof0uses the global font.
Set the parent Column's .layout.childGap, and give each Button .sizing = { Grow(), Fit() }. The width fills the sidebar, and the height fits the padding and content.
Install the X11 and GL development headers listed under Building: Linux, or install a raylib package so CMake can skip FetchContent.
Override explicitly:
cmake -S . -B build \
-DCCOMPOSE_RAYLIB_VERSION=5.5 \
-Draylib_ROOT=/path/to/raylib/installOr delete build/ and rebuild with -DCCOMPOSE_BACKEND_RAYLIB=OFF -DCCOMPOSE_BACKEND_RAYLIB=ON to force a clean FetchContent.
You asked for a standard your compiler doesn't support:
cmake -S . -B build -DCCOMPOSE_C_STANDARD=11 # safest
cmake -S . -B build -DCCOMPOSE_C_STANDARD=17
cmake -S . -B build -DCCOMPOSE_C_STANDARD=23 # needs a modern compilerMSVC and older GCC versions may not accept 23 even with a recent ccompose.
- Read the API comments in
include/ccompose.h. - Use
tests/smoke_test.cas a minimal headless program. - Use
examples/demo.cas an interactive raylib example. - File an issue in the ccompose repository with a minimal reproducer.