PCH警告:标头停止不能在宏或#if块中 - Visual C++ 2010 Express SP1

pig*_*d10 68 c++ visual-c++

这是从一个可能正在运作的网站上粘贴的.我做了一些谷歌搜索,发现我现在的问题是我今天下载的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
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)

Kas*_*ash 88

我有同样的问题,正在寻找解决方案.以下为我工作:

#pragma once在文件的开头添加(甚至在#ifndef APP_STATE_H标题保护之前)

  • @MarkStorer以前帖子中的以下链接有最好的解释[http://connect.microsoft.com/VisualStudio/feedback/details/651405/pch-warning-after-installing-sp1](http://connect.microsoft. com/VisualStudio/feedback/details/651405/pch-warning-after-installing-sp1) - Intellisense引擎对带有标题停止但未包含在任何.c/.cpp文件中的头文件感到高兴. (13认同)
  • @Kash链接已死。 (2认同)

Han*_*ant 15

您可能使用项目模板开始并丢弃预先生成的源代码文件.那些项目模板喜欢打开预编译的头文件,因为它可以节省时间.在"解决方案资源管理器"窗口中,右键单击项目,"属性","C/C++","预编译标题".将"预编译标题"设置更改为"不使用".

  • 不,我没有使用它,并且没有预编译头. (3认同)

One*_*ble 5

1.关闭项目。2.重新打开项目,一切正常。这是我的经验。