There are too many errors for the IntelliSense eng

2019-08-02 19:34发布

Please leave the window-installer tag in - this Q/A is not for C++ experts, but for people like me, who use C++ when they have to. They may face this potential time-waster, and need a quick fix to get msi.h or other includes operational quickly. VS2017 templates must have changed quite a bit - I didn't see this issue before.


Visual Studio 2017 Community Edition with all available C++ components installed (perhaps this problem does not exist in the professional edition?).

  1. File => New => Project... => Visual C++\Windows Desktop\Windows Console Application => OK.
  2. Do a quick test build to verify there are no errors. Right click solution => Build. As stated no errors should show up.
  3. Now add this include for msi.h directly below #include stdafx.h right above the main() function in the console appliation's CPP file:
#include <msi.h>
// And just to make things link:
#pragma comment(lib, "msi.lib")
  1. A red error chevron should show up in the top left corner at the start of the first line comment saying on hover: "There are too many errors for the IntelliSense engine to function correctly, some of which may not be visible in the editor. PCH warning: an unknown error occurred. An IntelliSense PCH file was not generated."

  2. Doing a build now should reveal numerous errors. In my case from wincrypt.h - and it got me thinking about WIN32_LEAN_AND_MEAN - see answer below. I thought such basics would already be included.

I keep seeing this problem in all new C++ Windows Console Application projects, but when I try in an older project created with Visual Studio 2013 it compiles correctly with msi.h included along with the link pragma.

Judging from the error message there must be something wrong with the precompiled header (PCH). This is what threw me off.

1条回答
我欲成王,谁敢阻挡
2楼-- · 2019-08-02 20:20

UPDATE: Others have asked about the same error message for other include files (not MSI related). I guess this is a generic problem that strikes every now and then - probably with classes that are in little use (or include Windows.h - perhaps)?

As a general suggestion this might be a hidden dependency problem (an include that is missing), or an incorrect order of the include files (you need to change the order of your includes for some technical reason that is not immediately obvious) or a incorrect or missing define (like seen in the answer below the line underneath). My take on it: get on github.com and search for similar sample code.

These issues can be quite clunky to work out for those of us who need C++ occasionally, and otherwise be "well known" for the C++ pros (who fix it in seconds as second nature). C++ pros: please keep in mind that issues such as these can kill a whole day's worth of productivity for those of us forced to clunk around with C++ when we need to - and have no C++ pros around to ask - terrible situation that! :-) - I hereby declare a "be nice to your C++ guru - if you got them - day!").


In stdafx.h, try adding this after #pragma once and before other includes:

#define WIN32_LEAN_AND_MEAN
// Windows Header Files:
#include <windows.h>

Now try to rebuild your solution and see if the problem has disappeared.

Though simple, the strangeness of the error message (seen in the question above) can throw people off course trying to figure out what is wrong. Also, this behavior seems new in VS2017 - template change.

It looks like including <atlstr.h> will also work, so that probably makes my problem more obscure. Could have sworn I tried this though - maybe after I made project settings changes that made it fail still (exactly what I hope to help others avoid).

If only these basic includes could be present in the file but commented out so they could be enabled quickly in sequence for testing - without any fuss.

查看更多
登录 后发表回答