Intellisense cannot open source file “*.h”

2019-01-26 09:11发布

问题:

I have no idea as to what may have happened. I was removing a few libraries I added to the VC folder and from Additional Dependencies (OpenGL libraries I've added), then when I tried to compile my program, I received 100 errors. The problem is that my current project is not recognizing some of the standard headers. Here is what I've got:

#include <Windows.h>    <-----Error from title
#include <stdio.h>      <-----Error from title
#include <stdlib.h>     <-----Error from title
#include "stdafx.h"     <-----OK
#include <CommCtrl.h>   <-----Error from title

I've created a new project to compare it's properties, but didn't notice anything missing. Does anyone have an idea as to why project isn't using these headers?

回答1:

Make sure you have all these paths under VC++ directories->Include Directories:

$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);‌​



回答2:

Just an update on previous answer, in VS2015, the previous method of including directories has been deprecated. Its now done on a per-solution basis. In the solution explorer right click your Project Name, then select properties, the dialog that opens up is similar to older VS. Add the paths as suggested above to the include directories and away you go.