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

This is pasted from a website that supposedly works. I did some search queries and found that the problem I am facing now is the result of Visual C ++ 2010 SP1, which I downloaded today, and now gives me this error:

PCH Warning: header stop cannot be in a macro or #if block.

Hope someone can help me!

 #ifndef APP_STATE_H #define APP_STATE_H #include "Framework.h" class AppState; //this line is giving me the error //define two classes #endif 

Framework.h:

 #ifndef OGRE_FRAMEWORK_H #define OGRE_FRAMEWORK_H #include <OgreCamera.h> #include <OgreEntity.h> #include <OgreLogManager.h> #include <OgreOverlay.h> #include <OgreOverlayElement.h> #include <OgreOverlayManager.h> #include <OgreRoot.h> #include <OgreViewport.h> #include <OgreSceneManager.h> #include <OgreRenderWindow.h> #include <OgreConfigFile.h> #include <OISEvents.h> #include <OISInputManager.h> #include <OISKeyboard.h> #include <OISMouse.h> class OgreFramework : public Ogre::Singleton<OgreFramework>,OIS::KeyListener,OIS::MouseListener{ public: OgreFramework(); ~OgreFramework(); bool initOgre(Ogre::String wndTitle, OIS::KeyListener *pKeyListener = 0, OIS::MouseListener *pMouseListener = 0); void updateOgre(double timeSinceLastFrame); //OIS bool keyPressed(const OIS::KeyEvent &keyEventRef); bool keyReleased(const OIS::KeyEvent &keyEventRef); bool mouseMoved(const OIS::MouseEvent &evt); bool mousePressed(const OIS::MouseEvent &evt, OIS::MouseButtonID id); bool mouseReleased(const OIS::MouseEvent &evt, OIS::MouseButtonID id); Ogre::Root* mRoot; Ogre::RenderWindow* mRenderWnd; Ogre::Viewport* mViewport; Ogre::Log* mLog; Ogre::Timer* mTimer; //OIS OIS::InputManager* mInputMgr; OIS::Keyboard* mKeyboard; OIS::Mouse* mMouse; private: OgreFramework(const OgreFramework&); OgreFramework& operator= (const OgreFramework&); }; #endif 
+67
c ++ visual-c ++
May 14 '11 at 17:32
source share
12 answers

I had the same problem and was looking for a solution. After me worked:

Add #pragma once at the beginning of the file (even before protecting the #ifndef APP_STATE_H )

+86
Jun 07 2018-11-11T00:
source share

You probably used the project template to get started and threw away the pre-created source code files. These project templates include the inclusion of precompiled headers, as this is such a time saver. Right-click your project in the "Solution Explorer", "Properties", "C / C ++", "Precompiled Headers" window. Change the Precompiled Header option to Do Not Use.

+13
May 14 '11 at 18:40
source share

move the #include statements outside the #if #end block

+4
Jul 07 '14 at 9:12
source share

1. Close the project. 2. Cut the project, and everything is in order. this is my expeirence.

+4
Dec 09 '14 at 8:30
source share

IntelliSense Database Recovery solves the problem.

  • Close Visual Studio
  • Delete [SolutionName] .sdf
  • Delete DllWrappers.opensdf
  • Delete ipch folder
  • Open Visual Studio
+3
Nov 13 '14 at 15:24
source share

I had the same problem. My solution was to add the missing ';' at the end of the class definition. Although this does not seem to apply to your problem, others who come here with the same error might find this helpful.

+2
Apr 17 '15 at 4:48
source share

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

+1
Jul 07 '12 at 3:20
source share

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

+1
Jun 23 '14 at 6:51
source share

I found that my .h file is actually being processed as a .cpp file! Right-click the file in Solution Explorer> All Configurations> Item Type: C / C ++ Header

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

+1
Jul 31 '14 at 10:22
source share

Once you add the .cpp file and include the header, this error should go away. I read where else this is a mistake.

0
30 Oct. '14 at 21:47
source share

I am using Visual Studio to edit Linux projects. For me, the problem was present when I included string.h in my precompiled header file. This was caused by lines with the __asm ​​operator, for example:

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

The solution was to define the following macro in the project properties, configuration properties, C / C ++, preprocessor, preprocessor definitions:

 __asm(x)= 
0
May 14 '19 at 7:44
source share

This happens to me when I do this:

file ah:

 #include "bh" . . . 

bh file:

 #include "ah" . . . 
-one
02 Sep '15 at 16:32
source share



All Articles