4

I am getting a strange Intellisense error in VS 2010. I searched the Internet with no luck. It seem that no one else got this error before.

IntelliSense: PCH warning: header stop needs to be at global scope. An intellisense PCH file was not generated. 

Following this many other errors as it stops indexing. This happens to the recent files that I have added. I have many files in my project (278) and this happens to the most recent 5-6 of them. May be I did something it doesn't like or may be there is a limitation.

Since I couldn't found this error even in the documentation, I would like to learn the reason as well as a possible solution. Note that, I have tried to delete ipch folder and sdf file to get them generated a new. The error is given to the last line of a file. My code heavily uses templates.

EDIT:
I noticed my ipch folder is mostly empty. This probably means that entire precompiled header generation fails, rather for those files. Still, intellisense partially works, but not for those files.

7
  • I use VS 2008, and that could be the difference, but for me, the Intellisense database is stored in a NCB file. Deleting that usually fixes my Intellisense problems. Commented Jan 26, 2012 at 21:26
  • They changed the entire system with VS2010 now it depends on precompiled headers and uses mssql database to store entries. Normally ipch folder takes over 100mb and now its almost empty. Commented Jan 26, 2012 at 21:30
  • 1
    could be related social.msdn.microsoft.com/Forums/en-SG/vsdebug/thread/… Commented Jan 26, 2012 at 21:30
  • do you use Visual Studio 2010 Professional (DreamSpark Version), SP1 Beta ? Commented Jan 26, 2012 at 21:32
  • None of the work arounds offered there works for me. Commented Jan 26, 2012 at 21:41

3 Answers 3

8

This error is generated when you forget a ";" after a class declaration, for example:

#ifndef _MYCLASS_H class MyClass { ... public: ... } #endif <--- VS2010 report here the error PCH: warning... 

If you put a ";" after the closing "}" the error go away. I'm not saying this is the only cause, I'm just saying that I found that error with the missing ";" in the mentioned place.

Sign up to request clarification or add additional context in comments.

Comments

7

PCH stand for "pre-compiled header" - you'll need to make sure you have these configured correctly.

The error message seems to be saying that the header configured as the 'stop' for precompiled headers is being included in a nested fashion (ie., some other header is including it). By default, a solution will use stdafx.h as the 'stop' header and the idiom is that stdafx.h will be the first header included in any .cpp or .c file. Don't include stdafx.h in any other header.

The best information about how Intellisense works and how to troubleshoot it come from the Visual C++ Team Blog.

A few articles that might be helpful:

6 Comments

My project does not use pch but intellisense uses it. It creates the folder for it but its totally empty.
May be i have a recursive include. This worths investigation. Pragmas protect to get a compilation error but probably intellisense ignores them.
Is there a way to have more logging information about intellisense? Like the list of the files it tried to parse.
I've updated the answer to include some pointers to articles that provide some IntelliSense details that may be helpful to you. It looks like turning on pre-compiled headers might help you troubleshoot this problem.
I'm not familiar with how GCC's precompiled header support works. On the other hand, you might be able to work around adding the #include in 100 files by using the /FI option ("Advanced/Forced Include File" in the IDE project settings).
|
1

My initial feeling is that it could be a file encoding problem, but anyway here's how I would approach figuring it out...

Create a brand new solution, does the intellisense work? If not then a VS reinstall might be in order.

If intellisense works in a different solution then there are 2 possibilities: something in your solution is screwy, or something in your folder hierarchy is screwy (permissions maybe?)

I'd delete the entire solution folder and get the latest from source control.

If it still occurs after that and you really want to find the cause, then you could remove a load of files from the project, see if the intellisense now works, remove some more... until a) you run out of files or b) you find the file that causes the error.

If a) then make a brand new solution and add your files and projects to it. If that works then compare your new solution/project files with the old ones to see what's different.

If b) then add the files back in and start pruning until you find the offending line.

2 Comments

It creates the same error in two different computers that are synced with svn. All other projects are working pretty well. I guess your brute force approach will take some time (278 files with more than 40k lines of code). At least I know that the problem happened after the last few files. Might worth a try.
I am now exploring another option. I have install Visual AssistX. I disabled the intellisense. Currently it seems OK. I might buy it as soon as I am sure that it works 100%.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.