From 9211595821cec0e37e0ec9d2d60ad1aaaa3f6134 Mon Sep 17 00:00:00 2001 From: Nic Barker Date: Sat, 28 Sep 2024 20:54:41 +1200 Subject: [PATCH] Try CLAY__INIT replacement --- CMakeLists.txt | 6 +++--- clay.h | 8 +++++--- .../raylib-sidebar-scrolling-container/CMakeLists.txt | 5 ++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1cf2e6d..9bbe6d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,9 @@ cmake_minimum_required(VERSION 3.28) project(clay) -if(MSVC) -add_subdirectory("examples/cpp-project-example") -elseif() +if(!MSVC) add_subdirectory("examples/raylib-sidebar-scrolling-container") add_subdirectory("examples/clay-official-website") +else() +add_subdirectory("examples/cpp-project-example") endif() \ No newline at end of file diff --git a/clay.h b/clay.h index f6d7c5d..750e983 100644 --- a/clay.h +++ b/clay.h @@ -454,14 +454,16 @@ extern uint32_t Clay__debugViewWidth; #ifdef __cplusplus #define CLAY__ALIGNMENT(type) alignof(type) +#define CLAY__INIT(type) type #elif +#define CLAY__INIT(type) (type) #define CLAY__ALIGNMENT(type) (offsetof(struct { char c; type x; } a, a.x)) #endif bool Clay__warningsEnabled = true; -Clay_String CLAY__SPACECHAR = (Clay_String) { .length = 1, .chars = " " }; -Clay_String CLAY__STRING_DEFAULT = (Clay_String) { .length = 0, .chars = "" }; +Clay_String CLAY__SPACECHAR = CLAY__INIT(Clay_String) { .length = 1, .chars = " " }; +Clay_String CLAY__STRING_DEFAULT = CLAY__INIT(Clay_String) { .length = 0, .chars = "" }; typedef struct { @@ -652,7 +654,7 @@ Clay_LayoutConfig *Clay__LayoutConfigArray_Add(Clay__LayoutConfigArray *array, C #pragma endregion // __GENERATED__ template -Clay_RectangleElementConfig CLAY__RECTANGLE_ELEMENT_CONFIG_DEFAULT = (Clay_RectangleElementConfig){0}; +Clay_RectangleElementConfig CLAY__RECTANGLE_ELEMENT_CONFIG_DEFAULT = (Clay_RectangleElementConfig){{0}}; // __GENERATED__ template array_define,array_add TYPE=Clay_RectangleElementConfig NAME=Clay__RectangleElementConfigArray DEFAULT_VALUE=&CLAY__RECTANGLE_ELEMENT_CONFIG_DEFAULT #pragma region generated diff --git a/examples/raylib-sidebar-scrolling-container/CMakeLists.txt b/examples/raylib-sidebar-scrolling-container/CMakeLists.txt index 15b0a1d..9d185d1 100644 --- a/examples/raylib-sidebar-scrolling-container/CMakeLists.txt +++ b/examples/raylib-sidebar-scrolling-container/CMakeLists.txt @@ -1,7 +1,5 @@ cmake_minimum_required(VERSION 3.28) -project(clay_examples_raylib_sidebar_scrolling_container) - -target_compile_options(clay_examples_raylib_sidebar_scrolling_container PUBLIC -Wall -Werror -Wno-unknown-pragmas) +project(clay_examples_raylib_sidebar_scrolling_container C) # Adding Raylib include(FetchContent) @@ -21,6 +19,7 @@ FetchContent_MakeAvailable(raylib) add_executable(clay_examples_raylib_sidebar_scrolling_container main.c multi-compilation-unit.c) +target_compile_options(clay_examples_raylib_sidebar_scrolling_container PUBLIC -Wall -Werror -Wno-unknown-pragmas) target_include_directories(clay_examples_raylib_sidebar_scrolling_container PUBLIC .) target_link_libraries(clay_examples_raylib_sidebar_scrolling_container PUBLIC raylib)