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

2021-12-22 00:00:00 visual-c++ c++

这是从一个网站粘贴过来的,该网站可能正在运行.我做了一些谷歌搜索,发现我现在遇到的问题是我今天下载的 Visual C++ 2010 SP1 的结果,现在给了我这个错误:

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 today, and is now giving me this error:

PCH 警告:标题停止不能在宏或 #if 块中.

希望有人能帮我解决这个问题!

Hopefully someone will be able to help me with this!

#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:

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

推荐答案

我遇到了同样的问题,正在寻找解决方案.以下对我有用:

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

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

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

相关文章