From 1410faca492aaa96626990381fe555fe45e5d692 Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Wed, 23 Oct 2024 00:39:17 +0200 Subject: [PATCH] Main: add debug build guard on Ogre::Root triggers LNK2019 on Ogre::DebugBuild::Root --- OgreMain/include/OgrePrerequisites.h | 13 +++++++++++++ OgreMain/include/OgreRoot.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/OgreMain/include/OgrePrerequisites.h b/OgreMain/include/OgrePrerequisites.h index 24e583f25be..3eb3880349a 100644 --- a/OgreMain/include/OgrePrerequisites.h +++ b/OgreMain/include/OgrePrerequisites.h @@ -32,6 +32,17 @@ THE SOFTWARE #include #include +// extra namespace to trigger LNK2019 on binary incompatible builds +// instead of crashing at runtime +#if defined(_MSC_VER) && defined(_DEBUG) +#define OGRE_DEBUG_NS_BEGIN namespace DEBUG_BUILD_REQUIRED { +#define OGRE_DEBUG_NS_END } +namespace Ogre { namespace DEBUG_BUILD_REQUIRED { } using namespace DEBUG_BUILD_REQUIRED; } +#else +#define OGRE_DEBUG_NS_BEGIN +#define OGRE_DEBUG_NS_END +#endif + namespace Ogre { #define OGRE_TOKEN_PASTE_INNER(x, y) x ## y #define OGRE_TOKEN_PASTE(x, y) OGRE_TOKEN_PASTE_INNER(x, y) @@ -211,7 +222,9 @@ namespace Ogre { class ResourceGroupManager; class ResourceManager; class RibbonTrail; +OGRE_DEBUG_NS_BEGIN class Root; +OGRE_DEBUG_NS_END class SceneManager; class SceneNode; class SceneQuery; diff --git a/OgreMain/include/OgreRoot.h b/OgreMain/include/OgreRoot.h index e8f176ba2f4..085761a1da6 100644 --- a/OgreMain/include/OgreRoot.h +++ b/OgreMain/include/OgreRoot.h @@ -55,6 +55,8 @@ namespace Ogre /// Scene manager instances, indexed by instance name typedef std::map SceneManagerInstanceMap; + OGRE_DEBUG_NS_BEGIN + /** The root class of the Ogre system. The Ogre::Root class represents a starting point for the client @@ -925,6 +927,7 @@ namespace Ogre */ Real getDefaultMinPixelSize() { return mDefaultMinPixelSize; } }; + OGRE_DEBUG_NS_END /** @} */ /** @} */ } // Namespace Ogre