From 70f79793d82bf1537aa12367804d5c080ef42d7d Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Tue, 21 Oct 2025 15:16:06 +0900 Subject: [PATCH 1/2] build: Implement strict pointer types option Signed-off-by: Hiroshi Hatake --- CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4cf122fd233..1059ddb8779 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,6 +158,7 @@ option(FLB_SMALL "Optimise for small size" No) set(FLB_SECURITY "ReleaseOnly" CACHE STRING "Build with security optimizations") set_property(CACHE FLB_SECURITY PROPERTY STRINGS "On;Off;ReleaseOnly") option(FLB_COVERAGE "Build with code-coverage" No) +option(FLB_COMPILER_STRICT_POINTER_TYPES "Build with -Werror=incompatible-pointer-types" No) option(FLB_JEMALLOC "Build with Jemalloc support" No) option(FLB_REGEX "Build with Regex support" Yes) option(FLB_UTF8_ENCODER "Build with UTF8 encoding support" Yes) @@ -450,6 +451,17 @@ if(FLB_COVERAGE) set(CMAKE_BUILD_TYPE "Debug") endif() +if(FLB_COMPILER_STRICT_POINTER_TYPES) + if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|AppleClang") + add_compile_options(-Werror=incompatible-pointer-types) + endif() + # Currently, AppleClang has more struct rules when using -Werror=incompatible-pointer-types. + # We still permit to discarding const qualifiers warnings. + if(CMAKE_C_COMPILER_ID MATCHES "AppleClang") + add_compile_options(-Wno-incompatible-pointer-types-discards-qualifiers) + endif() +endif() + # Enable Debug symbols if specified if(MSVC) set(CMAKE_BUILD_TYPE None) # Avoid flag conflicts (See CMakeList.txt:L18) From 9bd8e769f123f1a4469c62be46456623ddb17723 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Tue, 21 Oct 2025 15:15:40 +0900 Subject: [PATCH 2/2] workflows: Add CI task for strict pointer types Signed-off-by: Hiroshi Hatake --- .github/workflows/unit-tests.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index 0028a040268..e89036ec3ac 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -53,6 +53,7 @@ jobs: - "-DFLB_SIMD=On" - "-DFLB_SIMD=Off" - "-DFLB_ARROW=On" + - "-DFLB_COMPILER_STRICT_POINTER_TYPES=On" cmake_version: - "3.31.6" compiler: @@ -71,6 +72,10 @@ jobs: compiler: cc: clang cxx: clang++ + - flb_option: "-DFLB_COMPILER_STRICT_POINTER_TYPES=On" + compiler: + cc: clang + cxx: clang++ permissions: contents: read steps: