]> git.ipfire.org Git - thirdparty/curl.git/commit
windows: use built-in `_WIN32` macro to detect Windows
authorViktor Szakats <commit@vsz.me>
Tue, 21 Nov 2023 16:54:49 +0000 (16:54 +0000)
committerViktor Szakats <commit@vsz.me>
Wed, 22 Nov 2023 15:42:25 +0000 (15:42 +0000)
commite9a7d4a1c8377dbcf9a2d94365f60e3e5dff48f8
tree35d6e040280d03b15d1c5386fba092ce5e00f4d0
parent1c37d472a01c12ec9f8c7f7fc037448486a3b159
windows: use built-in `_WIN32` macro to detect Windows

Windows compilers define `_WIN32` automatically. Windows SDK headers
or build env defines `WIN32`, or we have to take care of it. The
agreement 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 using `WIN32`, `__WIN32__` and `CURL_WIN32` for
Windows detection, next to the official `_WIN32`. After this patch it
only uses `_WIN32` for this. Also, make it stop defining `CURL_WIN32`.

There is a slight chance these break compatibility with Windows
compilers that fail to define `_WIN32`. I'm not aware of any obsolete
or 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 using `WIN32` anymore.

- apply minor formatting here and there.

- delete unnecessary checks for `!MSDOS` when `_WIN32` is present.

Co-authored-by: Jay Satiro
Reviewed-by: Daniel Stenberg
Closes #12376
99 files changed:
docs/examples/10-at-a-time.c
docs/examples/anyauthput.c
docs/examples/cookie_interface.c
docs/examples/externalsocket.c
docs/examples/ftpupload.c
docs/examples/ipv6.c
docs/libcurl/symbols-in-versions
include/curl/curl.h
lib/asyn-ares.c
lib/cf-socket.c
lib/curl_memory.h
lib/curl_multibyte.c
lib/curl_multibyte.h
lib/curl_path.h
lib/curl_rtmp.c
lib/curl_setup.h
lib/curl_setup_once.h
lib/easy.c
lib/file.c
lib/functypes.h
lib/getenv.c
lib/idn.c
lib/memdebug.c
lib/memdebug.h
lib/mime.c
lib/netrc.c
lib/rand.c
lib/rand.h
lib/rename.c
lib/select.c
lib/smb.c
lib/socketpair.c
lib/strdup.c
lib/strdup.h
lib/strerror.c
lib/strerror.h
lib/system_win32.c
lib/system_win32.h
lib/timediff.c
lib/timeval.c
lib/transfer.c
lib/url.c
lib/urlapi.c
lib/urldata.h
lib/version.c
lib/version_win32.c
lib/version_win32.h
lib/vquic/curl_quiche.c
lib/vtls/keylog.c
lib/warnless.c
lib/warnless.h
scripts/checksrc.pl
src/tool_cb_hdr.c
src/tool_cb_prg.c
src/tool_cb_rea.c
src/tool_cb_see.h
src/tool_cb_wrt.c
src/tool_dirhie.c
src/tool_doswin.c
src/tool_doswin.h
src/tool_filetime.c
src/tool_filetime.h
src/tool_findfile.c
src/tool_findfile.h
src/tool_getparam.c
src/tool_getpass.c
src/tool_main.c
src/tool_operate.c
src/tool_operhlp.c
src/tool_parsecfg.c
src/tool_sdecls.h
src/tool_setup.h
src/tool_sleep.c
src/tool_urlglob.c
src/tool_util.c
tests/libtest/first.c
tests/libtest/lib1517.c
tests/libtest/lib1531.c
tests/libtest/lib1560.c
tests/libtest/lib1960.c
tests/libtest/lib3026.c
tests/libtest/lib518.c
tests/libtest/lib537.c
tests/libtest/lib670.c
tests/libtest/test.h
tests/libtest/testutil.c
tests/libtest/testutil.h
tests/server/getpart.c
tests/server/mqttd.c
tests/server/resolve.c
tests/server/rtspd.c
tests/server/sockfilt.c
tests/server/socksd.c
tests/server/sws.c
tests/server/tftpd.c
tests/server/util.c
tests/server/util.h
tests/unit/unit1394.c
tests/unit/unit1604.c