proxygen
Windows.h
Go to the documentation of this file.
1 /*
2  * Copyright 2016-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 // Only do anything if we are on windows.
20 #ifdef _WIN32
21 // This header is intended to be used in-place of including <Windows.h>,
22 // <WinSock2.h>, <io.h> or <direct.h>.
23 // It includes all of them, and undefines certain names defined by them that
24 // are used in places in Folly.
25 //
26 // These have to be this way because we define our own versions
27 // of close(), because the normal Windows versions don't handle
28 // sockets at all.
29 #ifndef __STDC__
30 /* nolint */
31 #define __STDC__ 1
32 #include <direct.h> // @manual nolint
33 #include <io.h> // @manual nolint
34 #undef __STDC__
35 #else
36 #include <direct.h> // @manual nolint
37 #include <io.h> // @manual nolint
38 #endif
39 
40 #if defined(min) || defined(max)
41 #error Windows.h needs to be included by this header, or else NOMINMAX needs \
42  to be defined before including it yourself.
43 #endif
44 
45 // This is needed because, for some absurd reason, one of the windows headers
46 // tries to define "min" and "max" as macros, which messes up most uses of
47 // std::numeric_limits.
48 #ifndef NOMINMAX
49 #define NOMINMAX 1
50 #endif
51 
52 #include <WinSock2.h> // @manual
53 #include <Windows.h> // @manual
54 
55 #ifdef CAL_GREGORIAN
56 #undef CAL_GREGORIAN
57 #endif
58 
59 // Defined in the GDI interface.
60 #ifdef ERROR
61 #undef ERROR
62 #endif
63 
64 // Defined in minwindef.h
65 #ifdef IN
66 #undef IN
67 #endif
68 
69 // Defined in winerror.h
70 #ifdef NO_ERROR
71 #undef NO_ERROR
72 #endif
73 
74 // Defined in minwindef.h
75 #ifdef OUT
76 #undef OUT
77 #endif
78 
79 // Defined in minwindef.h
80 #ifdef STRICT
81 #undef STRICT
82 #endif
83 
84 // Defined in Winbase.h
85 #ifdef Yield
86 #undef Yield
87 #endif
88 
89 #endif