-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
windows: use built-in _WIN32
macro to detect Windows
#12376
Conversation
- Warn via checksrc if symbol WIN32 is used in preprocessor lines.
My initial reaction to this was it's unnecessary, even though it is "more correct". We already use WIN32 and it works fine. However it is, yes, more correct. My biggest concern I think is that we will occasionally forget WIN32 is now _WIN32 and make the mistake of using the former. To that end I've added a checksrc warning category BANNEDPREPROC that checks for banned symbols (eg WIN32) on preprocessor lines. |
- Suppress checksrc warning WIN32 macro eval for CURL_WIN32
Good idea to make I'm thinking to sync
This would be a reboot of 1adebe7 What do you think? |
I struggle to think of when _WIN32 isn't available. Let's see if anyone else has anything to say on it... Ref: #4855 |
Some references:
One list mentions Borland C++, so I made a test with Can't think of more niche compilers that are still around. But if there are, they can almost certainly set |
include/curl/curl.h
Outdated
#if (defined(_WIN32) || defined(__WIN32__) || defined(WIN32)) && \ | ||
#if (defined(_WIN32) || \ | ||
defined(WIN32) /* !checksrc! disable BANNEDPREPROC 1 */ || \ | ||
defined(__WIN32__)) && \ | ||
!defined(__SYMBIAN32__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ref: #12378
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's curious that
_WIN32
or__WIN32__
could end up together with__SYMBIAN32__
, so that it had to be guarded-out.
It's been too long for me to recall for certain, but it may have been for x86 builds targeting the Symbian emulator running on Win32.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with also removing CURL_WIN32
from the public header. We never documented it for any purpose. It is mentioned in symbols-in-version
simply because it is present in curl.h
but I don't think we break any promises (API/ABI) by taking it away again.
This is a reboot of 1adebe7 and 8bd863f + curl#4854 + curl#4855, but instead of keeping around CURL_WIN32 as a replacement for our local WIN32 we just rely on _WIN32, which works universally out of the box. Ref: curl#12376 (comment)
``` Missing symbols mentioned in symbols-in-versions Add them to a header, or mark them as removed. CURL_WIN32 ``` Ref: https://github.com/curl/curl/actions/runs/6956411932/job/18927212026#step:11:1957
This fix was supposed to be committed earlier, but ended up missing from the final commit. Follow-up to e9a7d4a curl#12376 Closes #xxxxx
Follow-up to e9a7d4a curl#12376
Follow-up to e9a7d4a curl#12376 Closes curl#14963
Windows compilers define
_WIN32
automatically. Windows SDK headersor build env defines
WIN32
, or we have to take care of it. Theagreement seems to be that
_WIN32
is the preferred practice here.Make the source code rely on that to detect we're building for Windows.
Public
curl.h
was usingWIN32
,__WIN32__
andCURL_WIN32
forWindows detection, next to the official
_WIN32
. After this patch itonly uses
_WIN32
for this. Also, make it stop definingCURL_WIN32
.There is a slight chance these break compatibility with Windows
compilers that fail to define
_WIN32
. I'm not aware of any obsoleteor modern compiler affected, but in case there is one, one possible
solution is to define this macro manually.
grepping for
WIN32
remains useful to discover Windows-specific code.Also:
extend
checksrc
to ensure we're not usingWIN32
anymore.apply minor formatting here and there.
delete unnecessary checks for
!MSDOS
when_WIN32
is present.Closes #12376