Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curl.h: stop defining non-curl __has_declspec_attribute #16491

Closed
wants to merge 4 commits into from

Conversation

vszakats
Copy link
Member

@vszakats vszakats commented Feb 26, 2025

Public curl headers are best not to define 3rd-party or system macros.
Introduce CURL_HAS_DECLSPEC_ATTRIBUTE to cover this system macro and
use it.

Detected by test1167 after dropping the indentation:

test 1167...[Verify curl prefix of public symbols in header files]

/usr/bin/perl -I. -I.  returned 1, when expecting 0
 1167: exit FAILED
== Contents of files in the log/10/ dir after test 1167
=== Start of file server.cmd
 Testnum 1167
=== End of file server.cmd
=== Start of file stdout1167
 Bad symbols in public header files:
   __has_declspec_attribute(x)
=== End of file stdout1167

Ref: https://github.com/curl/curl/actions/runs/13533200900/job/37819784405?pr=16490#step:42:2087

Ref: https://clang.llvm.org/docs/LanguageExtensions.html#has-declspec-attribute
Follow-up to 50482b8 #3616
Ref: #16496 (fixing test1167)

Public curl headers are best not to define 3rd-party or system macros.
Instead check for this macro in the `#if` condition before use.

Detected by test1167 after dropping the indentation:
```
test 1167...[Verify curl prefix of public symbols in header files]

/usr/bin/perl -I. -I.  returned 1, when expecting 0
 1167: exit FAILED
== Contents of files in the log/10/ dir after test 1167
=== Start of file server.cmd
 Testnum 1167
=== End of file server.cmd
=== Start of file stdout1167
 Bad symbols in public header files:
   __has_declspec_attribute(x)
=== End of file stdout1167
```
Ref: https://github.com/curl/curl/actions/runs/13533200900/job/37819784405?pr=16490#step:42:2087

Follow-up to 50482b8 curl#3616
@vszakats vszakats changed the title include: stop defining non-curl __has_declspec_attribute curl.h: stop defining non-curl __has_declspec_attribute Feb 26, 2025
@vszakats vszakats marked this pull request as draft February 26, 2025 00:07
to avoid (Linux CM rustls):
```
In file included from /home/runner/work/curl/curl/lib/altsvc.c:31,
                 from /home/runner/work/curl/curl/lib/CMakeFiles/libcurl_shared.dir/Unity/unity_0_c.c:4:
/home/runner/work/curl/curl/include/curl/curl.h:120:31: error: missing binary operator before token "("
  120 |       __has_declspec_attribute(dllexport) && \
      |                               ^
```
https://github.com/curl/curl/actions/runs/13533471707/job/37820659780?pr=16491#step:36:49
@vszakats vszakats marked this pull request as ready for review February 26, 2025 00:24
@vszakats vszakats closed this in dbbbf71 Feb 26, 2025
@vszakats vszakats deleted the curlh-has-decl branch February 26, 2025 12:11
vszakats added a commit to vszakats/curl that referenced this pull request Feb 26, 2025
Before this patch, it missed this in `curl/curl.h`:
```c
#  define __has_declspec_attribute(x) 0
```
After this patch:
```
test 1167...[Verify curl prefix of public symbols in header files]
/usr/bin/perl -I. -I.  returned 1, when expecting 0
 1167: exit FAILED
== Contents of files in the log/14/ dir after test 1167
=== Start of file server.cmd
 Testnum 1167
=== End of file server.cmd
=== Start of file stdout1167
 Bad symbols in public header files:
   __has_declspec_attribute(x)
=== End of file stdout1167
FAIL 1167: 'Verify curl prefix of public symbols in header files' source analysis
TESTFAIL: These test cases failed: 1167
```

Ref: curl#16491
Closes curl#16496
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.

1 participant