• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // This file is designed to be included if windows.h is included from a source
6 // file that should not need it. Conditionally including this file from a few
7 // key source files will help to stop windows.h from creeping back into the
8 // Chromium build, with the namespace pollution which that implies. Typical
9 // usage is:
10 //
11 // // This should be after all other #includes.
12 // #if defined(_WINDOWS_)  // Detect whether windows.h was included.
13 // #include "base/win/windows_h_disallowed.h"
14 // #endif  // defined(_WINDOWS_)
15 //
16 // If it is not obvious why Windows.h is getting included, a quick way to
17 // determine the #include path is to edit your local Windows.h (e.g.,
18 // third_party\depot_tools\win_toolchain\vs_files\698eb5635a\Windows Kits\10\
19 // Include\10.0.26100.0\um\Windows.h) to add
20 //
21 // #error Windows.h included
22 //
23 // at the top and recompile the file(s) that are unexpectedly including
24 // Windows.h, e.g.,
25 //
26 // autoninja -C out/Default
27 // obj\chrome\browser\devtools\devtools\devtools_window.obj
28 //
29 // That will generate a compile error with the #include path.
30 // Then, undo the change to Windows.h.
31 //
32 // See https://crbug.com/796644 for more historical context.
33 
34 #ifndef BASE_WIN_WINDOWS_H_DISALLOWED_H_
35 #define BASE_WIN_WINDOWS_H_DISALLOWED_H_
36 
37 #error Windows.h was included unexpectedly. See comment above for details.
38 
39 #endif  // BASE_WIN_WINDOWS_H_DISALLOWED_H_
40