PCH Warning: header stop cannot be in a macro or #if block - Visual C++ 2010 Express SP1

前端 未结 11 548
不知归路
不知归路 2020-12-07 23:53

This is pasted from a website, which presumably was working. I did some googling and found that the issue I have now is a result of Visual C++ 2010 SP1, which I downloaded t

相关标签:
11条回答
  • 2020-12-08 00:20

    This is probable a day late and a dollar short but I had the same error when I accidentally put my header file in a .cpp file instead of a .h file. I will post it though in case it can help someone.

    0 讨论(0)
  • 2020-12-08 00:21

    I found that my .h file was actually being treated as a .cpp file! Right click on the file in the Solution Explorer > All Configurations > Item Type: C/C++ header

    Make sure the item type is not C/C++ compiler or other.

    0 讨论(0)
  • 2020-12-08 00:23

    I just added a referenct to the header file (#include "header.h") and it helped.

    0 讨论(0)
  • 2020-12-08 00:25

    You probably used a project template to get started and threw away the pre-generated source code files. Those project templates like to turn on precompiled headers because it is such a time-saver. Right-click your project in the Solution Explorer window, Properties, C/C++, Precompiled Headers. Change the "Precompiled Header" setting to "Not Using".

    0 讨论(0)
  • 2020-12-08 00:25

    I use Visual Studio to edit Linux projects. For me, the issue was present when I include string.h in my precompiled header file. It was caused by lines that have an __asm statement, for example:

    __THROW __asm ("memchr") __attribute_pure__ __nonnull ((1));
    

    The solution was to define the following macro under Project Properties, Configuration Properties, C/C++, Preprocessor, Preprocessor Defines:

    __asm(x)=
    
    0 讨论(0)
  • 2020-12-08 00:28

    I had the same issue and was looking for a solution. Following worked for me:

    Add #pragma once at the start of the file (even before the #ifndef APP_STATE_H header guard)

    0 讨论(0)
提交回复
热议问题