From 4b4637a445f6338992e967db301f62cd7c7e2937 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 20 Feb 2026 15:03:17 +0100 Subject: [PATCH] build: disable typecheck via the command-line instead of `curl_config.h` To make it apply to examples. This in turn makes analyzers run quicker and with fewer false positives. It's a special disable option, having its effect via `curl/curl.h`. Bug: https://github.com/curl/curl/pull/20649#issuecomment-3934885021 Follow-up to 9e6f1c5efb7a70e1f33e467a738f3e3f652f3174 #19637 Closes #20650 --- CMakeLists.txt | 5 +++++ configure.ac | 3 ++- lib/curl_config-cmake.h.in | 3 --- tests/test1165.pl | 15 +++++++++++---- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23e1099874..154ba5ef8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -504,6 +504,11 @@ mark_as_advanced(CURL_DISABLE_TYPECHECK) option(CURL_DISABLE_VERBOSE_STRINGS "Disable verbose strings" OFF) mark_as_advanced(CURL_DISABLE_VERBOSE_STRINGS) +if(CURL_DISABLE_TYPECHECK) + # Set it via the command-line to make it apply to examples also. + set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "CURL_DISABLE_TYPECHECK") +endif() + if(CURL_DISABLE_HTTP) set(CURL_DISABLE_ALTSVC ON) set(CURL_DISABLE_HSTS ON) diff --git a/configure.ac b/configure.ac index 091424cf2e..d345f5f354 100644 --- a/configure.ac +++ b/configure.ac @@ -4338,7 +4338,8 @@ AS_HELP_STRING([--disable-typecheck],[Disable type checking]), [ case "$enableval" in no) AC_MSG_RESULT(no) - AC_DEFINE(CURL_DISABLE_TYPECHECK, 1, [to disable type checking]) + dnl Set it via the command-line to make it apply to examples also. + CPPFLAGS="$CPPFLAGS -DCURL_DISABLE_TYPECHECK" curl_typecheck_msg="no" ;; *) diff --git a/lib/curl_config-cmake.h.in b/lib/curl_config-cmake.h.in index 7b622909b8..8742ad64af 100644 --- a/lib/curl_config-cmake.h.in +++ b/lib/curl_config-cmake.h.in @@ -163,9 +163,6 @@ /* disables TFTP */ #cmakedefine CURL_DISABLE_TFTP 1 -/* disables curl_easy_setopt()/curl_easy_getinfo() type checking */ -#cmakedefine CURL_DISABLE_TYPECHECK 1 - /* disables verbose strings */ #cmakedefine CURL_DISABLE_VERBOSE_STRINGS 1 diff --git a/tests/test1165.pl b/tests/test1165.pl index 5546fbded9..bcf8b50fb7 100755 --- a/tests/test1165.pl +++ b/tests/test1165.pl @@ -47,7 +47,9 @@ sub scanconf { while() { if(/(CURL_DISABLE_[A-Z0-9_]+)/g) { my ($sym)=($1); - $disable{$sym} = 1; + if(not $sym =~ /^(CURL_DISABLE_TYPECHECK)$/) { + $disable{$sym} = 1; + } } } close S; @@ -70,7 +72,7 @@ sub scanconf_cmake { while() { if(/(CURL_DISABLE_[A-Z0-9_]+)/g) { my ($sym)=($1); - if(not $sym =~ /^(CURL_DISABLE_INSTALL|CURL_DISABLE_SRP)$/) { + if(not $sym =~ /^(CURL_DISABLE_INSTALL|CURL_DISABLE_SRP|CURL_DISABLE_TYPECHECK)$/) { $hashr->{$sym} = 1; } } @@ -86,7 +88,10 @@ sub scan_cmake_config_h { scanconf_cmake(\%disable_cmake_config_h, "$root/lib/curl_config-cmake.h.in"); } -my %whitelisted = ('CURL_DISABLE_DEPRECATION' => 1); +my %whitelisted = ( + 'CURL_DISABLE_DEPRECATION' => 1, + 'CURL_DISABLE_TYPECHECK' => 1, +); sub scan_file { my ($source)=@_; @@ -128,7 +133,9 @@ sub scan_docs { $line++; if(/^## `(CURL_DISABLE_[A-Z0-9_]+)`/g) { my ($sym)=($1); - $docs{$sym} = $line; + if(not $sym =~ /^(CURL_DISABLE_TYPECHECK)$/) { + $docs{$sym} = $line; + } } } close F;