MongoDB C++ Driver legacy-1.1.2
Loading...
Searching...
No Matches
windows_basic.h
1// windows_basic.h
2
3/*
4 * Copyright 2010 10gen Inc.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#pragma once
20
21#if !defined(_WIN32)
22#error "windows_basic included but _WIN32 is not defined"
23#endif
24
25// "If you define NTDDI_VERSION, you must also define _WIN32_WINNT":
26// http://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx
27#if defined(NTDDI_VERSION) && !defined(_WIN32_WINNT)
28#error NTDDI_VERSION defined but _WIN32_WINNT is undefined
29#endif
30
31// Ensure that _WIN32_WINNT is set to something before we include windows.h. For server builds
32// both _WIN32_WINNT and NTDDI_VERSION are set as defines on the command line, but we need
33// these here for things like client driver builds, where they may not already be set.
34#if !defined(_WIN32_WINNT)
35// Can't use symbolic versions here, since we may not have seen sdkddkver.h yet.
36#if defined(_WIN64)
37// 64-bit builds default to Windows Server 2003 support.
38#define _WIN32_WINNT 0x0502
39#else
40// 32-bit builds default to Windows XP support.
41#define _WIN32_WINNT 0x0501
42#endif
43#endif
44
45// As above, but for NTDDI_VERSION. Otherwise, <windows.h> would set our NTDDI_VERSION based on
46// _WIN32_WINNT, but not select the service pack revision.
47#if !defined(NTDDI_VERSION)
48// Can't use symbolic versions here, since we may not have seen sdkddkver.h yet.
49#if defined(_WIN64)
50// 64-bit builds default to Windows Server 2003 SP 2 support.
51#define NTDDI_VERSION 0x05020200
52#else
53// 32-bit builds default to Windows XP SP 3 support.
54#define NTDDI_VERSION 0x05010300
55#endif
56#endif
57
58// No need to set WINVER, SdkDdkVer.h does that for us, we double check this below.
59
60// for rand_s() usage:
61#define _CRT_RAND_S
62
63// Do not complain that about standard library functions that Windows believes should have
64// underscores in front of them, such as unlink().
65#define _CRT_NONSTDC_NO_DEPRECATE
66
67// tell windows.h not to include a bunch of headers we don't need:
68#define WIN32_LEAN_AND_MEAN
69
70#include <winsock2.h> //this must be included before the first windows.h include
71#include <ws2tcpip.h>
72#include <wspiapi.h>
73#include <windows.h>
74
75// Should come either from the command line, or if not set there, the inclusion of sdkddkver.h
76// via windows.h above should set it based in _WIN32_WINNT, which is assuredly set by now.
77#if !defined(NTDDI_VERSION)
78#error "NTDDI_VERSION is not defined"
79#endif
80
81#if !defined(WINVER) || (WINVER != _WIN32_WINNT)
82#error "Expected WINVER to have been defined and to equal _WIN32_WINNT"
83#endif
84
85#if defined(_WIN64)
86#if !defined(NTDDI_WS03SP2) || (NTDDI_VERSION < NTDDI_WS03SP2)
87#error "64 bit mongo does not support Windows versions older than Windows Server 2003 SP 2"
88#endif
89#else
90#if !defined(NTDDI_WINXPSP3) || (NTDDI_VERSION < NTDDI_WINXPSP3)
91#error "32 bit mongo does not support Windows versions older than XP Service Pack 3"
92#endif
93#endif