Skip to content

Fixed warnings by improving ISO C compliance - #596

Open
lazzy-cipher wants to merge 1 commit into
nicbarker:mainfrom
lazzy-cipher:main
Open

lazzy-cipher wants to merge 1 commit into
nicbarker:mainfrom
lazzy-cipher:main

Conversation

@lazzy-cipher

@lazzy-cipher lazzy-cipher commented Apr 5, 2026 •

Copy link
Copy Markdown

This PR fixes the following warnings I get when using Clay+Raylib with GCC 15.2.1 and with -Wall, -Wextra, and -pedantic enabled:

Changes done:

  • Replaced initializer braces {} and { 0 } with CLAY__DEFAULT_STRUCT
  • Remove extra trailing semicolon in struct definition
  • Cast signed int to uint32_t in comparison to fix signedness mismatch
  • Added /* fall through */ comment to suppress the implicit case fallthrough warning
  • Removed unused variables
  • Cast unused parameters to (void)
clay.h:3071:50: warning: ISO C forbids empty initializer braces before C23 [-Wpedantic]
 3071 |             Clay_Dimensions contentSizeCurrent = {};
      |                                                  ^

clay.h:160:79: warning: ISO C forbids empty initializer braces before C23 [-Wpedantic]
  160 | #define CLAY__CONFIG_WRAPPER(type, ...) (CLAY__INIT(CLAY__WRAPPER_TYPE(type)) { __VA_ARGS__ }).wrapped
      |                                                                               ^
clay.h:3313:21: note: in expansion of macro ‘CLAY_AUTO_ID’
 3313 |                     CLAY_AUTO_ID() {
      |                     ^~~~~~~~~~~~

clay.h: In function ‘Clay__RenderDebugView’:
clay.h:3635:72: warning: ISO C forbids empty initializer braces before C23 [-Wpedantic]
 3635 |                     CLAY(CLAY_ID("Clay__DebugViewElementInfoPadding"), { }) {
      |

clay.h:3739:84: warning: ISO C forbids empty initializer braces before C23 [-Wpedantic]
 3739 |                             CLAY(CLAY_ID("Clay__DebugViewElementInfoAspectRatio"), { }) {
      |                                                                                    ^

clay.h:4369:2: warning: ISO C does not allow extra ‘;’ outside of a function [-Wpedantic]
 4369 | };
      |  ^

clay.h:4484:114: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
 4484 |                             if (config->exit.siblingOrdering == CLAY_EXIT_TRANSITION_ORDERING_NATURAL_ORDER && j == data->siblingIndex) {
      |

clay_renderer_raylib.c:235:31: warning: ISO C forbids empty initializer braces before C23 [-Wpedantic]
  235 |                     (Vector2) {},
      |                               ^

clay.h:2257:54: warning: unused parameter ‘deltaTime’ [-Wunused-parameter]
 2257 | void Clay__SizeContainersAlongAxis(bool xAxis, float deltaTime, Clay__int32_tArray* textElementsOut, Clay__int32_tArray* aspectRatioElementsOut) {
      |                                                ~~~~~~^~~~~~~~~

clay.h: In function ‘Clay__CalculateFinalLayout’:
clay.h:3114:48: warning: unused variable ‘childMapItem’ [-Wunused-variable]
 3114 |                 Clay_LayoutElementHashMapItem* childMapItem = Clay__GetHashMapItem(childElement->id);
      |                                                ^~~~~~~~~~~~

clay.h: In function ‘Clay__DebugViewRenderElementConfigHeader’:
clay.h:3449:59: warning: unused parameter ‘elementId’ [-Wunused-parameter]
 3449 | void Clay__DebugViewRenderElementConfigHeader(Clay_String elementId, Clay__DebugElementConfigType type) {
      |                                               ~~~~~~~~~~~~^~~~~~~~~

clay.h: In function ‘Clay__CloneElementsWithExitTransition’:
clay.h:4360:41: warning: unused variable ‘newChildElement’ [-Wunused-variable]
 4360 |                     Clay_LayoutElement* newChildElement = Clay_LayoutElementArray_Set_DontTouchLength(&context->layoutElements, nextIndex, *childElement);
      |                                         ^~~~~~~~~~~~~~~

clay.h:4343:39: warning: unused variable ‘config’ [-Wunused-variable]
 4343 |         Clay_TransitionElementConfig* config = &data->elementThisFrame->config.transition;
      |                                       ^~~~~~

@rats159

rats159 commented May 13, 2026

Copy link
Copy Markdown
Contributor

Should also explicitly use void in 0-parameter functions, looks like Clay__CloneElementsWithExitTransition is the only real function that has this issue. there's also a fully empty Clay__CreateDebugView function which has the issue.

Also, Clay_LayoutElement uses an anonymous union and anonymous struct which is C11. This looks harder to fix though, unfortunately.

@lazzy-cipher
lazzy-cipher force-pushed the main branch 2 times, most recently from 896da28 to b360955 Compare May 13, 2026 11:20
@lazzy-cipher

Copy link
Copy Markdown
Author

Should also explicitly use void in 0-parameter functions, looks like Clay__CloneElementsWithExitTransition is the only real function that has this issue. there's also a fully empty Clay__CreateDebugView function which has the issue.

Also, Clay_LayoutElement uses an anonymous union and anonymous struct which is C11. This looks harder to fix though, unfortunately.

While non-void 0 parameter functions don't give warnings in most compilers, I added void to the parameters of Clay_GetLayoutDimensions() and Clay__CloneElementsWithExitTransition().

Also, I fixed the merge conflicts.

@erasmussen1 erasmussen1 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants