VirtualBox

source: vbox/trunk/include/iprt/win/windows.h@ 94676

Last change on this file since 94676 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 KB
Line 
1/** @file
2 * Safe way to include Windows.h.
3 */
4
5/*
6 * Copyright (C) 2016-2022 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef IPRT_INCLUDED_win_windows_h
27#define IPRT_INCLUDED_win_windows_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32
33/* winioctl.h in windows 10 SDKs up to 22000(?) has a warning(push/pop) bug in the
34 portion taken from ntddscm.h causing trouble when using _WIN32_WINNT or NTDDI_VERSION
35 older than NTDDI_WIN10_RS5. In 18362 winioctl.h also tests against _WIN32_WINNT_WIN10_TH2
36 and other sdkddkver.h defines which only exist in NTDDI variants, not in _WIN32_WINNT_XXX,
37 so we fake up those too to keep the precompiler warning free.
38
39 Work around this by blocking out the buggy section on winioctl.h for now if the
40 NTDDI_VERSION target is too small.
41
42 WDK_NTDDI_VERSION is not present in the W7 SDK, not sure when exactly it was added.
43 NTDDI_WIN10_RS5 is W10 1809. NTDDI_WIN10_CO is Windows 11? */
44#include <sdkddkver.h>
45#ifdef _WIN32_WINNT_WIN10
46# ifndef _WIN32_WINNT_WIN10_TH2
47# define _WIN32_WINNT_WIN10_TH2 _WIN32_WINNT_WIN10
48# endif
49# ifndef _WIN32_WINNT_WIN10_RS1
50# define _WIN32_WINNT_WIN10_RS1 _WIN32_WINNT_WIN10
51# endif
52# ifndef _WIN32_WINNT_WIN10_RS2
53# define _WIN32_WINNT_WIN10_RS2 _WIN32_WINNT_WIN10
54# endif
55# ifndef _WIN32_WINNT_WIN10_RS3
56# define _WIN32_WINNT_WIN10_RS3 _WIN32_WINNT_WIN10
57# endif
58# ifndef _WIN32_WINNT_WIN10_RS4
59# define _WIN32_WINNT_WIN10_RS4 _WIN32_WINNT_WIN10
60# endif
61# ifndef _WIN32_WINNT_WIN10_RS5
62# define _WIN32_WINNT_WIN10_RS5 _WIN32_WINNT_WIN10
63# endif
64#endif
65#if defined(NTDDI_WIN10_RS5) && !defined(NTDDI_WIN10_CO) && defined(WDK_NTDDI_VERSION)
66# if NTDDI_VERSION < NTDDI_WIN10_RS5
67# define _NTDDSCM_H_ buggy, hope nobody needs it.
68# endif
69#endif
70
71#ifdef _MSC_VER
72/*
73 * Unfortunately, the Windows.h file in SDK 7.1 is not clean wrt warning C4668:
74 * wincrypt.h(1848) : warning C4668: 'NTDDI_WINLH' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
75 */
76# pragma warning(push)
77# pragma warning(disable:4668)
78# pragma warning(disable:4480) /* W10/wincrypt.h(9193) : warning C4480: nonstandard extension used: specifying underlying type for enum 'CertKeyType' */
79# if _MSC_VER >= 1800 /*RT_MSC_VER_VC120*/
80# pragma warning(disable:4005) /* sdk/v7.1/include/sal_supp.h(57) : warning C4005: '__useHeader' : macro redefinition */
81# endif
82# ifdef __cplusplus
83# if _MSC_VER >= 1900 /*RT_MSC_VER_VC140*/
84# pragma warning(disable:5039) /* winbase.h(13179): warning C5039: 'TpSetCallbackCleanupGroup': pointer or reference to potentially throwing function passed to 'extern "C"' function under -EHc. Undefined behavior may occur if this function throws an exception. */
85# endif
86# else
87# pragma warning(disable:4255) /* warning C4255: 'FARPROC' : no function prototype given: converting '()' to '(void)' */
88# endif
89#endif
90
91#include <Windows.h>
92
93#ifdef _MSC_VER
94# pragma warning(pop)
95/* VS2010: Something causes this to be re-enabled above and triggering errors using RT_FLEXIBLE_ARRAY. */
96# pragma warning(disable:4200)
97#endif
98
99#endif /* !IPRT_INCLUDED_win_windows_h */
100
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette