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

PCH Warning: header stop cannot be in a macro or #if block - Visual C++ 2010 Express SP1 (PCH 警告:标题停止不能在宏或 #if 块中 - Visual C++ 2010 Express SP1)

本文介绍了PCH 警告:标题停止不能在宏或 #if 块中 - Visual C++ 2010 Express SP1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是从一个网站粘贴过来的,该网站可能正在运行.我做了一些谷歌搜索,发现我现在遇到的问题是我今天下载的 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)

这篇关于PCH 警告:标题停止不能在宏或 #if 块中 - Visual C++ 2010 Express SP1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

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

基础教程推荐