• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2010 Vicente J. Botet Escriba
3  * Copyright 2015-2018 Andrey Semashev
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * See http://www.boost.org/LICENSE_1_0.txt
7  */
8 
9 #ifndef BOOST_WINAPI_BASIC_TYPES_HPP_INCLUDED_
10 #define BOOST_WINAPI_BASIC_TYPES_HPP_INCLUDED_
11 
12 #include <boost/winapi/config.hpp>
13 
14 #ifdef BOOST_HAS_PRAGMA_ONCE
15 #pragma once
16 #endif
17 
18 #if defined(BOOST_USE_WINDOWS_H)
19 # include <windows.h>
20 #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
21 # ifdef UNDER_CE
22 #  ifndef WINAPI
23 #   ifndef _WIN32_WCE_EMULATION
24 #    define WINAPI  __cdecl     // Note this doesn't match the desktop definition
25 #   else
26 #    define WINAPI  __stdcall
27 #   endif
28 #  endif
29 // Windows CE defines a few functions as inline functions in kfuncs.h
30 typedef int BOOL;
31 typedef unsigned long DWORD;
32 typedef void* HANDLE;
33 typedef HANDLE HGLOBAL;
34 typedef void* LPVOID;
35 #  include <kfuncs.h>
36 # endif // UNDER_CE
37 #else
38 # error "Win32 functions not available"
39 #endif
40 
41 #include <boost/winapi/detail/header.hpp>
42 
43 #if defined(_M_IX86) || defined(__i386__)
44 #define BOOST_WINAPI_DETAIL_STDCALL __stdcall
45 #else
46 // On architectures other than 32-bit x86 __stdcall is ignored. Clang also issues a warning.
47 #define BOOST_WINAPI_DETAIL_STDCALL
48 #endif
49 
50 #if defined(WINAPI)
51 #define BOOST_WINAPI_WINAPI_CC WINAPI
52 #else
53 #define BOOST_WINAPI_WINAPI_CC BOOST_WINAPI_DETAIL_STDCALL
54 #endif
55 
56 #if defined(CALLBACK)
57 #define BOOST_WINAPI_CALLBACK_CC CALLBACK
58 #else
59 #define BOOST_WINAPI_CALLBACK_CC BOOST_WINAPI_DETAIL_STDCALL
60 #endif
61 
62 #if defined(NTAPI)
63 #define BOOST_WINAPI_NTAPI_CC NTAPI
64 #else
65 #define BOOST_WINAPI_NTAPI_CC BOOST_WINAPI_DETAIL_STDCALL
66 #endif
67 
68 #ifndef NO_STRICT
69 #ifndef STRICT
70 #define STRICT 1
71 #endif
72 #endif
73 
74 #if defined(STRICT)
75 #define BOOST_WINAPI_DETAIL_DECLARE_HANDLE(x) struct x##__; typedef struct x##__ *x
76 #else
77 #define BOOST_WINAPI_DETAIL_DECLARE_HANDLE(x) typedef void* x
78 #endif
79 
80 #if !defined(BOOST_USE_WINDOWS_H)
81 extern "C" {
82 union _LARGE_INTEGER;
83 struct _SECURITY_ATTRIBUTES;
84 BOOST_WINAPI_DETAIL_DECLARE_HANDLE(HINSTANCE);
85 typedef HINSTANCE HMODULE;
86 }
87 #endif
88 
89 #if defined(__GNUC__)
90 #define BOOST_WINAPI_DETAIL_EXTENSION __extension__
91 #else
92 #define BOOST_WINAPI_DETAIL_EXTENSION
93 #endif
94 
95 // MinGW64 gcc 4.8.2 fails to compile function declarations with boost::winapi::VOID_ arguments even though
96 // the typedef expands to void. In Windows SDK, VOID is a macro which unfolds to void. We use our own macro in such cases.
97 #define BOOST_WINAPI_DETAIL_VOID void
98 
99 namespace boost {
100 namespace winapi {
101 #if defined(BOOST_USE_WINDOWS_H)
102 
103 typedef ::BOOL BOOL_;
104 typedef ::PBOOL PBOOL_;
105 typedef ::LPBOOL LPBOOL_;
106 typedef ::BOOLEAN BOOLEAN_;
107 typedef ::PBOOLEAN PBOOLEAN_;
108 typedef ::BYTE BYTE_;
109 typedef ::PBYTE PBYTE_;
110 typedef ::LPBYTE LPBYTE_;
111 typedef ::UCHAR UCHAR_;
112 typedef ::PUCHAR PUCHAR_;
113 typedef ::WORD WORD_;
114 typedef ::PWORD PWORD_;
115 typedef ::LPWORD LPWORD_;
116 typedef ::DWORD DWORD_;
117 typedef ::PDWORD PDWORD_;
118 typedef ::LPDWORD LPDWORD_;
119 typedef ::HANDLE HANDLE_;
120 typedef ::PHANDLE PHANDLE_;
121 typedef ::SHORT SHORT_;
122 typedef ::PSHORT PSHORT_;
123 typedef ::USHORT USHORT_;
124 typedef ::PUSHORT PUSHORT_;
125 typedef ::INT INT_;
126 typedef ::PINT PINT_;
127 typedef ::LPINT LPINT_;
128 typedef ::UINT UINT_;
129 typedef ::PUINT PUINT_;
130 typedef ::LONG LONG_;
131 typedef ::PLONG PLONG_;
132 typedef ::LPLONG LPLONG_;
133 typedef ::ULONG ULONG_;
134 typedef ::PULONG PULONG_;
135 typedef ::LONGLONG ULONG64_;
136 typedef ::ULONGLONG PULONG64_;
137 typedef ::LONGLONG LONGLONG_;
138 typedef ::ULONGLONG ULONGLONG_;
139 typedef ::INT_PTR INT_PTR_;
140 typedef ::UINT_PTR UINT_PTR_;
141 typedef ::LONG_PTR LONG_PTR_;
142 typedef ::ULONG_PTR ULONG_PTR_;
143 typedef ::DWORD_PTR DWORD_PTR_;
144 typedef ::PDWORD_PTR PDWORD_PTR_;
145 typedef ::SIZE_T SIZE_T_;
146 typedef ::PSIZE_T PSIZE_T_;
147 typedef ::SSIZE_T SSIZE_T_;
148 typedef ::PSSIZE_T PSSIZE_T_;
149 typedef VOID VOID_; // VOID is a macro
150 typedef ::PVOID PVOID_;
151 typedef ::LPVOID LPVOID_;
152 typedef ::LPCVOID LPCVOID_;
153 typedef ::CHAR CHAR_;
154 typedef ::LPSTR LPSTR_;
155 typedef ::LPCSTR LPCSTR_;
156 typedef ::WCHAR WCHAR_;
157 typedef ::LPWSTR LPWSTR_;
158 typedef ::LPCWSTR LPCWSTR_;
159 
160 #else // defined( BOOST_USE_WINDOWS_H )
161 
162 typedef int BOOL_;
163 typedef BOOL_* PBOOL_;
164 typedef BOOL_* LPBOOL_;
165 typedef unsigned char BYTE_;
166 typedef BYTE_* PBYTE_;
167 typedef BYTE_* LPBYTE_;
168 typedef unsigned char UCHAR_;
169 typedef UCHAR_* PUCHAR_;
170 typedef BYTE_ BOOLEAN_;
171 typedef BOOLEAN_* PBOOLEAN_;
172 typedef unsigned short WORD_;
173 typedef WORD_* PWORD_;
174 typedef WORD_* LPWORD_;
175 #if !defined(__LP64__)
176 typedef unsigned long DWORD_;
177 #else
178 typedef unsigned int DWORD_;
179 #endif
180 typedef DWORD_* PDWORD_;
181 typedef DWORD_* LPDWORD_;
182 typedef void* HANDLE_;
183 typedef void** PHANDLE_;
184 
185 typedef short SHORT_;
186 typedef SHORT_* PSHORT_;
187 typedef unsigned short USHORT_;
188 typedef USHORT_* PUSHORT_;
189 typedef int INT_;
190 typedef INT_* PINT_;
191 typedef INT_* LPINT_;
192 typedef unsigned int UINT_;
193 typedef UINT_* PUINT_;
194 #if !defined(__LP64__)
195 typedef long LONG_;
196 typedef unsigned long ULONG_;
197 #else
198 typedef int LONG_;
199 typedef unsigned int ULONG_;
200 #endif
201 typedef LONG_* PLONG_;
202 typedef LONG_* LPLONG_;
203 typedef ULONG_* PULONG_;
204 #if defined(BOOST_HAS_MS_INT64)
205 BOOST_WINAPI_DETAIL_EXTENSION typedef __int64 LONGLONG_;
206 BOOST_WINAPI_DETAIL_EXTENSION typedef unsigned __int64 ULONGLONG_;
207 #else
208 BOOST_WINAPI_DETAIL_EXTENSION typedef long long LONGLONG_;
209 BOOST_WINAPI_DETAIL_EXTENSION typedef unsigned long long ULONGLONG_;
210 #endif
211 typedef LONGLONG_ LONG64_, *PLONG64_;
212 typedef ULONGLONG_ ULONG64_, *PULONG64_;
213 
214 #if defined(_WIN64)
215 typedef LONGLONG_ INT_PTR_;
216 typedef ULONGLONG_ UINT_PTR_;
217 typedef LONGLONG_ LONG_PTR_;
218 typedef ULONGLONG_ ULONG_PTR_;
219 #else
220 typedef int INT_PTR_;
221 typedef unsigned int UINT_PTR_;
222 typedef long LONG_PTR_;
223 typedef unsigned long ULONG_PTR_;
224 #endif
225 
226 typedef ULONG_PTR_ DWORD_PTR_, *PDWORD_PTR_;
227 typedef ULONG_PTR_ SIZE_T_, *PSIZE_T_;
228 typedef LONG_PTR_ SSIZE_T_, *PSSIZE_T_;
229 
230 typedef void VOID_;
231 typedef void *PVOID_;
232 typedef void *LPVOID_;
233 typedef const void *LPCVOID_;
234 
235 typedef char CHAR_;
236 typedef CHAR_ *LPSTR_;
237 typedef const CHAR_ *LPCSTR_;
238 
239 typedef wchar_t WCHAR_;
240 typedef WCHAR_ *LPWSTR_;
241 typedef const WCHAR_ *LPCWSTR_;
242 
243 #endif // defined( BOOST_USE_WINDOWS_H )
244 
245 // ::NTSTATUS is defined in ntdef.h, which is not included by windows.h by default, so alwaus use LONG_
246 typedef LONG_ NTSTATUS_;
247 typedef NTSTATUS_ *PNTSTATUS_;
248 
249 typedef ::HMODULE HMODULE_;
250 
251 typedef union BOOST_MAY_ALIAS _LARGE_INTEGER {
252     BOOST_WINAPI_DETAIL_EXTENSION struct {
253         DWORD_ LowPart;
254         LONG_ HighPart;
255     };
256     struct {
257         DWORD_ LowPart;
258         LONG_ HighPart;
259     } u;
260     LONGLONG_ QuadPart;
261 } LARGE_INTEGER_, *PLARGE_INTEGER_;
262 
263 typedef struct BOOST_MAY_ALIAS _SECURITY_ATTRIBUTES {
264     DWORD_  nLength;
265     LPVOID_ lpSecurityDescriptor;
266     BOOL_   bInheritHandle;
267 } SECURITY_ATTRIBUTES_, *PSECURITY_ATTRIBUTES_, *LPSECURITY_ATTRIBUTES_;
268 
269 }
270 }
271 
272 #include <boost/winapi/detail/footer.hpp>
273 
274 #endif // BOOST_WINAPI_BASIC_TYPES_HPP_INCLUDED_
275