Commit 8dcf6bc6 authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

Add missing include file - include what you use

base_paths_win.cc needs the known folders GUIDs which are defined in
KnownFolders.h. It was including shlobj.h which *usually* brings in this
header file, but not always. The happy path is:
    shlobj.h includes
    shlobj_core.h which includes
    shlguid.h  which includes
    KnownFolders.h

However shlobj_core.h includes shlguid.h like this:
    #ifndef INITGUID
    #include <shlguid.h>
    #endif /* !INITGUID */

That's fine if shlguid.h is the only place that defines INITGUID, but it
isn't. It doesn't even define it - it includes another file that does.
That's terrible.

So, if you include shlobj.h you may or may not get KnownFolders.h. This
is sloppy on our part, and on Microsoft's.

This was found while experimenting with different jumbo-build settings -
FOLDERID_ApplicationShortcuts would not be defined if the wrong .cc
files were included first.

The investigation was done by compiling with /showIncludes to find out
why KnownFolders.h was sometimes included, and then find out why it
wasn't always.

The bug in shlobj_core.h was reported here:
https://developercommunity.visualstudio.com/content/problem/162527/shlguidh-is-incorrectly-included-by-shlobj-coreh.html

Change-Id: I57f7894a7016704d15d5b02bbcf518b318263db2
Reviewed-on: https://chromium-review.googlesource.com/813017
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522463}
parent 1de8a4ce
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
#include <windows.h> #include <windows.h>
#include <KnownFolders.h>
#include <shlobj.h> #include <shlobj.h>
#include "base/base_paths.h" #include "base/base_paths.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment