wrap inclusion of windows.h with appropriate defines

This commit is contained in:
arvidn 2018-11-20 16:05:40 +01:00 committed by Arvid Norberg
parent 1f9178f882
commit 50ae1838e6
11 changed files with 60 additions and 24 deletions

View File

@ -218,6 +218,7 @@ nobase_include_HEADERS = \
aux_/torrent_impl.hpp \
aux_/instantiate_connection.hpp \
aux_/range.hpp \
aux_/windows.hpp \
\
extensions/smart_ban.hpp \
extensions/ut_metadata.hpp \

View File

@ -48,10 +48,7 @@ POSSIBILITY OF SUCH DAMAGE.
#ifdef TORRENT_WINDOWS
// windows part
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include "libtorrent/aux_/windows.hpp"
#include <winioctl.h>
#include <sys/types.h>
#else

View File

@ -36,9 +36,9 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp"
#include "libtorrent/error_code.hpp"
#include "libtorrent/aux_/throw.hpp"
#include "libtorrent/aux_/windows.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <windows.h>
#include <wincrypt.h>
#include "libtorrent/aux_/disable_warnings_pop.hpp"

View File

@ -0,0 +1,50 @@
/*
Copyright (c) 2018, Arvid Norberg, Steven Siloti
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TORRENT_WINDOWS_HPP_INCLUDED
#define TORRENT_WINDOWS_HPP_INCLUDED
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN
#endif
#ifndef STRICT
#define STRICT
#endif
#include <windows.h>
#endif // TORRENT_WINDOWS_HPP_INCLUDED

View File

@ -49,10 +49,7 @@ POSSIBILITY OF SUCH DAMAGE.
#ifdef TORRENT_WINDOWS
// windows part
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include "libtorrent/aux_/windows.hpp"
#include <winioctl.h>
#include <sys/types.h>
#else

View File

@ -47,7 +47,7 @@ POSSIBILITY OF SUCH DAMAGE.
#ifdef TORRENT_WINDOWS
// windows.h must be included after stdlib.h under mingw
#include <windows.h>
#include "libtorrent/aux_/windows.hpp"
#endif
#ifdef TORRENT_MINGW

View File

@ -70,10 +70,7 @@ POSSIBILITY OF SUCH DAMAGE.
#endif // TORRENT_USE_SYSCTL
#if TORRENT_USE_GETIPFORWARDTABLE || TORRENT_USE_GETADAPTERSADDRESSES
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include "libtorrent/aux_/windows.hpp"
#include <iphlpapi.h>
#endif

View File

@ -39,10 +39,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <cstring>
#ifdef TORRENT_WINDOWS
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include "libtorrent/aux_/windows.hpp"
#endif
#if TORRENT_USE_ICONV

View File

@ -90,10 +90,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/utf8.hpp"
#include "libtorrent/aux_/win_util.hpp"
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include "libtorrent/aux_/windows.hpp"
#include <winioctl.h>
#ifndef TORRENT_MINGW
#include <direct.h> // for _getcwd, _mkdir

View File

@ -55,7 +55,7 @@ const rlim_t rlim_infinity = RLIM_INFINITY;
#endif
#if defined TORRENT_WINDOWS
#include <windows.h>
#include "libtorrent/aux_/windows.hpp"
#endif
#include "libtorrent/aux_/disable_warnings_pop.hpp"

View File

@ -51,7 +51,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <csignal>
#ifdef _WIN32
#include <windows.h> // fot SetErrorMode
#include "libtorrent/aux_/windows.hpp" // fot SetErrorMode
#include <io.h> // for _dup and _dup2
#include <process.h> // for _getpid
#include <crtdbg.h>