curl/curl.h: replace recursive macros with C++-friendly method to enforce 3 args#20709
curl/curl.h: replace recursive macros with C++-friendly method to enforce 3 args#20709vszakats wants to merge 5 commits intocurl:masterfrom
Conversation
|
It works to avoid recursive warnings in libcurl code, e.g. doh.c. And there is this particular case, where the call is wrapper in https://github.com/curl/curl/actions/runs/22349795920/job/64673656914?pr=20709 same with the bare compiler (w/o clang-tidy): In itself a niche case, but I find it interesting. |
|
@aisle-analyzer augment review |
🔒 Aisle Security Analysis✅ We scanned this PR and did not find any security vulnerabilities. Aisle supplements but does not replace security review. Analyzed PR: #20709 at commit |
🤖 Augment PR SummarySummary: Reworks the public 🤖 Was this summary useful? React with 👍 or 👎 |
There was a problem hiding this comment.
Pull request overview
This PR replaces recursive macros with a C++-friendly two-stage macro solution for enforcing exactly three arguments to curl functions (curl_easy_setopt, curl_easy_getinfo, curl_share_setopt, curl_multi_setopt). The previous recursive macro approach broke C++ code that used the :: namespace qualifier (e.g., ::curl_easy_setopt(...)) and an alternative non-recursive approach using parentheses (curl_easy_setopt) also broke this C++ pattern. The new two-stage solution uses a helper macro curl_exactly_three_arguments that expands to parenthesized arguments, avoiding both the recursive macro warnings and the C++ compatibility issues.
Changes:
- Introduced
curl_exactly_three_argumentshelper macro and updated four function macros to use the two-stage expansion pattern - Updated comments in build configuration files to reflect that recursive macro warnings from curl/curl.h now only occur in rare combinations rather than always
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| include/curl/curl.h | Replaced recursive macros with two-stage solution using curl_exactly_three_arguments helper macro for four functions |
| m4/curl-compilers.m4 | Updated comment to indicate -Wdisabled-macro-expansion warning is now primarily from standard headers, only rarely from curl/curl.h |
| CMake/PickyWarnings.cmake | Updated comment to match the m4 file change regarding warning source |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Certain uses may still trigger a C compiler warning
-Wdisabled-macro-expansionafter this, e.g. when the call is wrappedin the
CURL_IGNORE_DEPRECATION()macro as seen in docs/examples.Suggested-by: Kai Pastor
Ref: #20682 (comment)
Follow-up to ee9b000 #20686
Follow-up to daa6b27 #20597
With warnings temporarily re-enabled unrelated CI failures expected
due to recursive macros in 3rd-party headers.