From d68af1cbe08f55ee123b613a01f10e198984b130 Mon Sep 17 00:00:00 2001 From: Nic Barker Date: Sun, 29 Sep 2024 12:49:06 +1300 Subject: [PATCH] Final tweaks --- .github/workflows/cmake-multi-platform.yml | 2 -- CMakeLists.txt | 1 + README.md | 6 ++++-- clay.h | 10 +++------- examples/clay-official-website/CMakeLists.txt | 2 -- .../raylib-sidebar-scrolling-container/CMakeLists.txt | 1 + 6 files changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index e94e012..9d13830 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -1,5 +1,3 @@ -# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform. -# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml name: CMake on multiple platforms on: diff --git a/CMakeLists.txt b/CMakeLists.txt index 6adf9f9..cce9bb9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ project(clay) add_subdirectory("examples/cpp-project-example") +# Don't try to compile C99 projects using MSVC if(NOT MSVC) add_subdirectory("examples/raylib-sidebar-scrolling-container") add_subdirectory("examples/clay-official-website") diff --git a/README.md b/README.md index 63e5c6e..396c0ef 100644 --- a/README.md +++ b/README.md @@ -394,13 +394,15 @@ The supported directives are: - `CLAY_EXTEND_CONFIG_IMAGE` - Provide additional struct members to `CLAY_IMAGE_CONFIG` that will be passed through with output render commands. - `CLAY_EXTEND_CONFIG_CUSTOM` - Provide additional struct members to `CLAY_IMAGE_CONFIG` that will be passed through with output render commands. -### Bindings +### Bindings for non C -Clay is usable out of the box as a `.h` include in both C99 and C++ with designated initializer support. +Clay is usable out of the box as a `.h` include in both C99 and C++20 with designated initializer support. There are also supported bindings for other languages, including: - [Odin Bindings](https://github.com/nicbarker/clay/tree/main/bindings/odin) +Unfortunately clay does **not** support Microsoft C11 or C17 via MSVC at this time. + ### Debug Tools Clay includes built-in UI debugging tools, similar to the "inspector" in browsers such as Chrome or Firefox. These tools are included in `clay.h`, and work by injecting additional render commands into the output [Clay_RenderCommandArray](#clay_rendercommandarray). diff --git a/clay.h b/clay.h index bd9d3f9..2bb857d 100644 --- a/clay.h +++ b/clay.h @@ -28,12 +28,6 @@ #define CLAY_WASM_EXPORT(null) #endif -#ifdef _MSC_VER -#define CLAY_PACKED_ENUM : uint8_t -#else -#define CLAY_PACKED_ENUM __attribute__((__packed__)) -#endif - // Public Macro API ------------------------ #define CLAY_LAYOUT(...) Clay__StoreLayoutConfig(CLAY__INIT(Clay_LayoutConfig) {__VA_ARGS__ }) @@ -113,11 +107,13 @@ static int CLAY__ELEMENT_DEFINITION_LATCH = 0; Clay__CloseElementWithChildren() #ifdef __cplusplus -#define CLAY__ALIGNMENT(type) alignof(type) #define CLAY__INIT(type) type +#define CLAY__ALIGNMENT(type) alignof(type) +#define CLAY_PACKED_ENUM : uint8_t #else #define CLAY__INIT(type) (type) #define CLAY__ALIGNMENT(type) (offsetof(struct { char c; type x; }, x)) +#define CLAY_PACKED_ENUM __attribute__((__packed__)) #endif #ifdef __cplusplus diff --git a/examples/clay-official-website/CMakeLists.txt b/examples/clay-official-website/CMakeLists.txt index bca47c8..65087bb 100644 --- a/examples/clay-official-website/CMakeLists.txt +++ b/examples/clay-official-website/CMakeLists.txt @@ -5,9 +5,7 @@ set(CMAKE_C_STANDARD 99) add_executable(clay_official_website main.c) -if(!MSVC) target_compile_options(clay_official_website PUBLIC -Wall -Werror -Wno-unknown-pragmas) -endif() target_include_directories(clay_official_website PUBLIC .) set(CMAKE_CXX_FLAGS_RELEASE "-O3") \ No newline at end of file diff --git a/examples/raylib-sidebar-scrolling-container/CMakeLists.txt b/examples/raylib-sidebar-scrolling-container/CMakeLists.txt index 9d185d1..f93f628 100644 --- a/examples/raylib-sidebar-scrolling-container/CMakeLists.txt +++ b/examples/raylib-sidebar-scrolling-container/CMakeLists.txt @@ -1,5 +1,6 @@ cmake_minimum_required(VERSION 3.28) project(clay_examples_raylib_sidebar_scrolling_container C) +set(CMAKE_C_STANDARD 99) # Adding Raylib include(FetchContent)