program tip

PCH 경고 : 헤더 중지는 매크로 또는 #if 블록에있을 수 없음-Visual C ++ 2010 Express SP1

radiobox 2020. 11. 8. 09:45
반응형

PCH 경고 : 헤더 중지는 매크로 또는 #if 블록에있을 수 없음-Visual C ++ 2010 Express SP1


이것은 아마도 작동하는 웹 사이트에서 붙여 넣은 것입니다. 인터넷 검색을 수행 한 결과 현재 발생한 문제가 오늘 다운로드 한 Visual C ++ 2010 SP1의 결과라는 것을 발견했으며 이제이 오류가 발생합니다.

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

누군가가 나를 도울 수 있기를 바랍니다!

#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

나는 같은 문제가 있었고 해결책을 찾고있었습니다. 다음은 나를 위해 일했습니다.

#pragma once파일 시작 부분에 추가 ( #ifndef APP_STATE_H헤더 가드 이전에도 )


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".


1.Close the Project. 2.Reopen the project,and all ok. this is my expeirence.


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


Rebuilding IntelliSense database solves the problem.

  1. Close Visual Studio
  2. Delete [SolutionName].sdf
  3. Delete DllWrappers.opensdf
  4. Delete ipch folder
  5. Open Visual Studio

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


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.


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


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.


Once you add a .cpp file and have it include the header this error should go away. I've read some where else this is a bug.


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)=

참고URL : https://stackoverflow.com/questions/6003603/pch-warning-header-stop-cannot-be-in-a-macro-or-if-block-visual-c-2010-exp

반응형