Home Dashboard Directory Help
Search

PCH warning after installing SP1 by RobYull


Status: 

Closed
 as Duplicate Help for as Duplicate


6
0
Sign in
to vote
Type: Bug
ID: 651405
Opened: 3/14/2011 4:18:34 PM
Access Restriction: Public
1
Workaround(s)
view
5
User(s) can reproduce this bug

Description

After installing SP1 (release), I've begun getting an Intellisense error at the beginning of all of my header files, just past the header guards.

    1    IntelliSense: PCH warning: header stop cannot be in a macro or #if block. An intellisense PCH file was not generated.    e:\programming\ksframework\branches\sandbox\src\kslibrary\math\bigintmath.hpp    6

[code]
#ifndef    DEFINE_KS_MATH_BIGINTMATH_HPP
#define    DEFINE_KS_MATH_BIGINTMATH_HPP

namespace KS
{
}

#endif    //    DEFINE_KS_MATH_BIGINTMATH_HPP
[/code]

Intellisense shows the error on the word <b>namespace</b> and underlines it. It doesn't prevent compiling. But it looks like the header guards seem to be triggering this. It doesn't seem to show the error on #includes immediately following the start of the header guards, but anything following that so far has shown the error.

I have found that putting <b>#pragma once</b> at the beginning of the header silences the error.

It has done this in both library and console projects. None of the projects I've been working with were created using precompiled headers.
Details
Sign in to post a comment.
Posted by Robin Degen on 5/21/2011 at 8:31 AM
I also have this problem with the following code:


#ifndef chamber_h__
#define chamber_h__

class Chamber
{
public:
    Chamber();
    ~Chamber();

private:

protected:
};

#endif // chamber_h__

Which really makes no sense because there are way more headers and classes in this project, and this is the only one it has a problem with.
Posted by Microsoft on 3/18/2011 at 2:32 PM
Hello RobYull,

Thank for you reporting this issue. This is an duplicate of another internal bug report. We have fixed this internally already, but unfortunately, the bug fix didn't make it into SP1. It would be included in the future releases of VS.

You are quite correct. If the header is not included by any cpp file in your project/solution, you could potentially get a PCH warning. This is because our intellisense engine works with translation units instead of individual files. A translation unit is essentially a c/cpp file and all the header files that were included. When a header file, say x.h, is opened, VS searches the include graph and find a suitable .c/cpp file that includes x.h use that as the translation unit for the intellisense engine. However, if x.h is not found in the include graph (ie. not included by any .c/cpp file in the project), then the intellisense engine will use the header file itself as the translation unit (eg. treating that header file as a .c/cpp file). In that case, the intellisense engine won't be able to generate the iPCH due to the reason described by the error message itself.

As you already know, you can work around this by including the problematic headers in a .c/cpp file.

Thanks,
Alan Chan
Visual C++ Team

Posted by Microsoft on 3/18/2011 at 2:17 PM
Hello RobYull,

Thank for you reporting this issue. This is an duplicate of another internal bug report. We have fixed this internally already, but unfortunately, the bug fix didn't make it into SP1. It would be included in the future releases of VS.

You are quite correct. If the header is not included by any cpp file in your project/solution, you could potentially get a PCH warning. This is because our intellisense engine works with translation units instead of individual files. A translation unit is essentially a c/cpp file and all the header files that were included. When a header file, say x.h, is opened, VS searches the include graph and find a suitable .c/cpp file that includes x.h use that as the translation unit for the intellisense engine. However, if x.h is not found in the include graph (ie. not included by any .c/cpp file in the project), then the intellisense engine will use the header file itself as the translation unit (eg. treating that header file as a .c/cpp file). In that case, the intellisense engine won't be able to generate the iPCH due to the reason described by the error message itself.

As you already know, you can work around this by including the problematic headers in a .c/cpp file.

Thanks,
Alan Chan
Visual C++ Team

Posted by RobYull on 3/15/2011 at 5:24 AM
I've attached a test case. In the testcase, I found that the error was generated in the header if it was not included by a cpp file. Also I saw the error appear in the cpp file if there were no headers included (files are commented on what seems to work and not work).
Posted by Microsoft on 3/14/2011 at 11:36 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. In order to efficiently investigate and reproduce this issue, we are requesting additional information outlined below.

Could you please give us a demo project to demonstrate this issue so that we can conduct further research?

Please submit this information to us within 4 business days. We look forward to hearing from you with this information.

Microsoft Visual Studio Connect Support Team
Posted by Microsoft on 3/14/2011 at 5:15 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by Azarien on 5/29/2012 at 4:42 AM
Add a new .cpp file to your project that includes all the header files that display the warning:

#include "header_with_warning_1.h"
#include "header_with_warning_2.h"
// etc.
File Name Submitted By Submitted On File Size  
Screenshot.jpg (restricted) 3/14/2011 -
Screenshot.jpg 3/14/2011 331 KB
TestCase.zip 3/15/2011 2 KB