Skip to content

include: avoid recursive macros#20597

Closed
vszakats wants to merge 24 commits intocurl:masterfrom
vszakats:cm-typecheck-vs-warningopt
Closed

include: avoid recursive macros#20597
vszakats wants to merge 24 commits intocurl:masterfrom
vszakats:cm-typecheck-vs-warningopt

Conversation

@vszakats
Copy link
Member

@vszakats vszakats commented Feb 14, 2026

To fix potential -Wdisabled-macro-expansion warnings when using these
macros within other macros. Fixing for example:

lib/doh.c:328:3: error: disabled expansion of recursive macro [clang-diagnostic-disabled-macro-expansion,-warnings-as-errors]
  328 |   ERROR_CHECK_SETOPT(CURLOPT_URL, url);
      |   ^
lib/doh.c:271:14: note: expanded from macro 'ERROR_CHECK_SETOPT'
  271 |     result = curl_easy_setopt((CURL *)doh, x, y);       \
      |              ^
include/curl/curl.h:3332:44: note: expanded from macro 'curl_easy_setopt'
 3332 | #define curl_easy_setopt(handle,opt,param) curl_easy_setopt(handle,opt,param)
      |                                            ^
[...]

Also update comments on why curl continues to disable
-Wdisabled-macro-expansion and -Wused-but-marked-unused warnings.

Follow-up to 92f215f #18477


Disabling this warning probably should be done regardless of
picky warnings enabled or not. That's likely true for other no
options too, thus not tackled in this PR.

  • enable the warnings when possible. → TRIED, but these warnings
    pop up due to 3rd-party headers, e.g. Linux glibc (stdio/stderr),
    MUSL (sa_handler) and in OpenSSL 3 (due to ossl_unused used
    in its public headers). Meaning it's not possible to enable these.

@vszakats vszakats changed the title TEST: cmake: do not disable -Wdisabled-macro-expansion with typechecks disa… TEST: cmake: do not disable -Wdisabled-macro-expansion with typechecks disabled Feb 14, 2026
@vszakats vszakats marked this pull request as draft February 14, 2026 13:51
@vszakats vszakats changed the title TEST: cmake: do not disable -Wdisabled-macro-expansion with typechecks disabled TEST: cmake: enable -Wdisabled-macro-expansion when possible Feb 14, 2026
@vszakats vszakats force-pushed the cm-typecheck-vs-warningopt branch from 5d1fb1c to c3e6870 Compare February 15, 2026 12:33
@vszakats vszakats changed the title TEST: cmake: enable -Wdisabled-macro-expansion when possible build: stop disabling 2 picky warnings on conditions Feb 15, 2026
@vszakats vszakats marked this pull request as ready for review February 15, 2026 13:07
@vszakats vszakats changed the title build: stop disabling 2 picky warnings on conditions build: stop disabling 2 picky warnings if typecheck is inactive Feb 15, 2026
@vszakats vszakats requested a review from Copilot February 15, 2026 13:32

This comment was marked as off-topic.

@vszakats vszakats marked this pull request as draft February 15, 2026 14:45
@vszakats
Copy link
Member Author

vszakats commented Feb 15, 2026

CM libressl Fil-C:

In file included from /home/runner/work/curl/curl/lib/conncache.c:36:
/home/runner/work/curl/curl/lib/sigpipe.h:59:12: error: disabled expansion of recursive macro [-Werror,-Wdisabled-macro-expansion]
   59 |     action.sa_handler = SIG_IGN;
      |            ^
/home/runner/filc/build/bin/../../pizfix/include/signal.h:178:35: note: expanded from macro 'sa_handler'
  178 | #define sa_handler   __sa_handler.sa_handler
      |                                   ^
1 error generated.

https://github.com/curl/curl/actions/runs/22039030172/job/63676732424?pr=20597#step:42:45

CM clang HTTP/3 clang-tidy:

/Users/runner/work/curl/curl/lib/doh.c:328:3: error: disabled expansion of recursive macro [clang-diagnostic-disabled-macro-expansion,-warnings-as-errors]
  328 |   ERROR_CHECK_SETOPT(CURLOPT_URL, url);
      |   ^
/Users/runner/work/curl/curl/lib/doh.c:271:14: note: expanded from macro 'ERROR_CHECK_SETOPT'
  271 |     result = curl_easy_setopt((CURL *)doh, x, y);       \
      |              ^
/Users/runner/work/curl/curl/include/curl/curl.h:3332:44: note: expanded from macro 'curl_easy_setopt'
 3332 | #define curl_easy_setopt(handle,opt,param) curl_easy_setopt(handle,opt,param)
      |                                            ^
[...]

https://github.com/curl/curl/actions/runs/22039030164/job/63676732284?pr=20597#step:11:77

linux-mingw, CM clang-tidy:

/home/runner/work/curl/curl/lib/mprintf.c:685:4: error: 'snprintf' was marked unused but was used [clang-diagnostic-used-but-marked-unused,-warnings-as-errors]
  685 |   (snprintf)(work, BUFFSIZE, formatbuf, dnum);
      |    ^
1 warning generated.

https://github.com/curl/curl/actions/runs/22041102952/job/63682054988?pr=20597#step:8:103

@vszakats vszakats changed the title build: stop disabling 2 picky warnings if typecheck is inactive include: avoid recursive macro redefines Feb 15, 2026
@vszakats vszakats marked this pull request as ready for review February 15, 2026 19:50
@vszakats vszakats changed the title include: avoid recursive macro redefines include: avoid recursive macros Feb 15, 2026
@vszakats vszakats requested a review from Copilot February 15, 2026 21:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vszakats vszakats closed this in daa6b27 Feb 15, 2026
@vszakats vszakats deleted the cm-typecheck-vs-warningopt branch February 15, 2026 21:55
vszakats added a commit to vszakats/curl that referenced this pull request Feb 16, 2026
vszakats added a commit to vszakats/curl that referenced this pull request Feb 23, 2026
To avoid breaking 3rd-party code reusing these symbols as C++ methods,
e.g. in CMake sources:
```
cmake/src/v4.0.0-b30653ae0c.clean/Source/cmCurl.cxx:119:24: error: expected unqualified-id
  119 |     ::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_CAINFO, cafile.c_str());
      |                        ^
```

Follow-up to daa6b27 curl#20597
vszakats added a commit that referenced this pull request Feb 23, 2026
To avoid breaking 3rd-party code reusing these symbols as C++ methods,
e.g. in CMake sources:
```
cmake/src/v4.0.0-b30653ae0c.clean/Source/cmCurl.cxx:119:24: error: expected unqualified-id
  119 |     ::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_CAINFO, cafile.c_str());
      |                        ^
```

Also expand comment to highlight the case.

Reported-by: Kai Pastor
Bug: daa6b27#r177869049
Reported-by: Marcel Raad
Bug: https://curl.se/mail/lib-2026-02/0020.html
Fixes #20682
Follow-up to daa6b27 #20597

Closes #20686
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants