cmake: silence silly Apple clang warnings in C89 mode, test in CI

- `stdbool.h` is also included via system headers. Disabling it from curl
  does not fix it. Silencing lots of these:
  ```
  curl/lib/curlx/warnless.h:64:1: warning: '_Bool' is a C99 extension [-Wc99-extensions]
   64 | bool curlx_sztouz(ssize_t sznum, size_t *puznum);
      | ^
  /Library/Developer/CommandLineTools/usr/lib/clang/17/include/stdbool.h:24:14: note: expanded from macro 'bool'
   24 | #define bool _Bool
      |              ^
  ```

- silence `-Wcomma` warnings.
  in favor of the global silencing approach, since a couple of more of
  these were hit (in vquic, tool1622, unit1309, unit1636), and it seems
  silly to update them all.
  Revert e8189c4420 #20362

Also:
- cmake: include C standard in 'platform flags' log line.
- GHA/macos: switch a job to C89 to verify.
- GHA/linux: show 'C89' in job names.

Ref: https://cmake.org/cmake/help/v3.7/variable/CMAKE_C_STANDARD.html

Closes #20363
This commit is contained in:
Viktor Szakats 2026-01-19 23:24:47 +01:00
parent f07a98ae11
commit 09c9afdd71
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
5 changed files with 17 additions and 6 deletions

View File

@ -185,12 +185,12 @@ jobs:
tflags: '--min=910 951 to 9999' tflags: '--min=910 951 to 9999'
generate: -DENABLE_DEBUG=ON -DENABLE_THREADED_RESOLVER=OFF generate: -DENABLE_DEBUG=ON -DENABLE_THREADED_RESOLVER=OFF
- name: 'openssl intel' - name: 'openssl intel C89'
install_packages: libssh-dev install_packages: libssh-dev
install_steps: pytest install_steps: pytest
configure: CFLAGS=-std=gnu89 --with-openssl --with-libssh --enable-debug configure: CFLAGS=-std=gnu89 --with-openssl --with-libssh --enable-debug
- name: 'openssl arm' - name: 'openssl arm C89'
image: ubuntu-24.04-arm image: ubuntu-24.04-arm
install_steps: pytest install_steps: pytest
configure: CFLAGS=-std=gnu89 --with-openssl --enable-debug --disable-verbose configure: CFLAGS=-std=gnu89 --with-openssl --enable-debug --disable-verbose

View File

@ -257,11 +257,11 @@ jobs:
install: libressl install: libressl
install_steps: pytest install_steps: pytest
generate: -DENABLE_DEBUG=ON -DOPENSSL_ROOT_DIR=/opt/homebrew/opt/libressl -DCURL_DISABLE_LDAP=ON -DCURL_BROTLI=OFF -DCURL_ZSTD=OFF -DCURL_USE_LIBSSH2=OFF generate: -DENABLE_DEBUG=ON -DOPENSSL_ROOT_DIR=/opt/homebrew/opt/libressl -DCURL_DISABLE_LDAP=ON -DCURL_BROTLI=OFF -DCURL_ZSTD=OFF -DCURL_USE_LIBSSH2=OFF
- name: 'OpenSSL 10.15' - name: 'OpenSSL 10.15 C89'
compiler: clang compiler: clang
install: libnghttp3 libngtcp2 install: libnghttp3 libngtcp2
install_steps: pytest install_steps: pytest
generate: -DENABLE_DEBUG=ON -DOPENSSL_ROOT_DIR=/opt/homebrew/opt/openssl -DUSE_NGTCP2=ON -DCURL_BROTLI=OFF -DCURL_ZSTD=OFF -DCURL_USE_LIBSSH2=OFF generate: -DENABLE_DEBUG=ON -DOPENSSL_ROOT_DIR=/opt/homebrew/opt/openssl -DUSE_NGTCP2=ON -DCURL_BROTLI=OFF -DCURL_ZSTD=OFF -DCURL_USE_LIBSSH2=OFF -DCMAKE_C_STANDARD=90
macos-version-min: '10.15' macos-version-min: '10.15'
- name: 'OpenSSL SecTrust' - name: 'OpenSSL SecTrust'
compiler: clang compiler: clang

View File

@ -435,6 +435,15 @@ if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND MSVC)
endforeach() endforeach()
endif() endif()
if(CMAKE_C_STANDARD STREQUAL 90 AND CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 4.2)
list(APPEND _picky "-Wno-c99-extensions") # Avoid: warning: '_Bool' is a C99 extension
endif()
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1)
list(APPEND _picky "-Wno-comma") # Just silly
endif()
endif()
if(DOS AND CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0) if(DOS AND CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)
list(APPEND _picky "-Wno-arith-conversion") # Avoid warnings in DJGPP's built-in FD_SET() macro list(APPEND _picky "-Wno-arith-conversion") # Avoid warnings in DJGPP's built-in FD_SET() macro
endif() endif()

View File

@ -132,6 +132,9 @@ endif()
if(CMAKE_CROSSCOMPILING) if(CMAKE_CROSSCOMPILING)
string(APPEND _target_flags " CROSS") string(APPEND _target_flags " CROSS")
endif() endif()
if(CMAKE_C_STANDARD)
string(APPEND _target_flags " C${CMAKE_C_STANDARD}")
endif()
message(STATUS "CMake platform flags:${_target_flags}") message(STATUS "CMake platform flags:${_target_flags}")
if(CMAKE_CROSSCOMPILING) if(CMAKE_CROSSCOMPILING)

View File

@ -3058,8 +3058,7 @@ ParameterError parse_args(int argc, argv_item_t argv[])
ParameterError result = PARAM_OK; ParameterError result = PARAM_OK;
struct OperationConfig *config = global->first; struct OperationConfig *config = global->first;
stillflags = TRUE; for(i = 1, stillflags = TRUE; i < argc && !result; i++) {
for(i = 1; i < argc && !result; i++) {
orig_opt = convert_tchar_to_UTF8(argv[i]); orig_opt = convert_tchar_to_UTF8(argv[i]);
if(!orig_opt) if(!orig_opt)
return PARAM_NO_MEM; return PARAM_NO_MEM;