1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-07-29 13:01:14 +03:00

windows: use built-in _WIN32 macro to detect Windows

Instead of `WIN32`.

The compiler defines `_WIN32`. 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.

Minor downside is that CMake uses `WIN32` and we also adopted it in
`Makefile.mk`.

In public libssh2 headers we stick with accepting either `_WIN32` or
`WIN32` and define our own namespaced `LIBSSH2_WIN32` based on them.

grepping for `WIN32` remains useful to detect Windows-specific code.

Closes #1195
This commit is contained in:
Viktor Szakats
2023-09-29 08:43:40 +00:00
parent 4c241d5c65
commit 6fbc9505d8
33 changed files with 87 additions and 91 deletions

View File

@ -6,7 +6,7 @@
#include "libssh2_setup.h"
#include <libssh2.h>
#ifdef WIN32
#ifdef _WIN32
#include <ws2tcpip.h> /* for socklen_t */
#define recv(s, b, l, f) recv((s), (b), (int)(l), (f))
#define send(s, b, l, f) send((s), (b), (int)(l), (f))
@ -72,7 +72,7 @@ int main(int argc, char *argv[])
libssh2_socket_t listensock = LIBSSH2_INVALID_SOCKET;
libssh2_socket_t forwardsock = LIBSSH2_INVALID_SOCKET;
#ifdef WIN32
#ifdef _WIN32
char sockopt;
WSADATA wsadata;
@ -311,7 +311,7 @@ shutdown:
if(forwardsock != LIBSSH2_INVALID_SOCKET) {
shutdown(forwardsock, 2);
#ifdef WIN32
#ifdef _WIN32
closesocket(forwardsock);
#else
close(forwardsock);
@ -320,7 +320,7 @@ shutdown:
if(listensock != LIBSSH2_INVALID_SOCKET) {
shutdown(listensock, 2);
#ifdef WIN32
#ifdef _WIN32
closesocket(listensock);
#else
close(listensock);
@ -337,7 +337,7 @@ shutdown:
if(sock != LIBSSH2_INVALID_SOCKET) {
shutdown(sock, 2);
#ifdef WIN32
#ifdef _WIN32
closesocket(sock);
#else
close(sock);