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:
@ -33,7 +33,7 @@ static const char *password = "password";
|
||||
|
||||
static void portable_sleep(unsigned int seconds)
|
||||
{
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
Sleep(seconds);
|
||||
#else
|
||||
sleep(seconds);
|
||||
@ -53,7 +53,7 @@ int main(int argc, char *argv[])
|
||||
LIBSSH2_CHANNEL *channel;
|
||||
int counter;
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
WSADATA wsadata;
|
||||
|
||||
rc = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
@ -68,7 +68,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(getenv("USER"))
|
||||
username = getenv("USER");
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
else if(getenv("USERNAME"))
|
||||
username = getenv("USERNAME");
|
||||
#endif
|
||||
@ -254,7 +254,7 @@ shutdown:
|
||||
|
||||
if(sock != LIBSSH2_INVALID_SOCKET) {
|
||||
shutdown(sock, 2 /* SHUT_RDWR */);
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
closesocket(sock);
|
||||
#else
|
||||
close(sock);
|
||||
|
Reference in New Issue
Block a user