Skip to content

Commit

Permalink
#define OGRE_CURRENT_FUNCTION => __PRETTY_FUNCTION__ or __FUNCSIG__ o…
Browse files Browse the repository at this point in the history
…r __func__
  • Loading branch information
Eugene Golushkov committed Feb 13, 2025
1 parent b2e7006 commit a64b9b6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 51 deletions.
9 changes: 9 additions & 0 deletions OgreMain/include/OgrePlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,15 @@ THE SOFTWARE.
#define OGRE_QUOTE( x ) OGRE_QUOTE_INPLACE( x )
#define OGRE_WARN( x ) message( __FILE__ "(" QUOTE( __LINE__ ) ") : " x "\n" )

// portable analog of __PRETTY_FUNCTION__, see also BOOST_CURRENT_FUNCTION
#if OGRE_COMPILER == OGRE_COMPILER_GNUC || OGRE_COMPILER == OGRE_COMPILER_CLANG
# define OGRE_CURRENT_FUNCTION __PRETTY_FUNCTION__
#elif OGRE_COMPILER == OGRE_COMPILER_MSVC || defined( __FUNCSIG__ )
# define OGRE_CURRENT_FUNCTION __FUNCSIG__
#else // C++11
# define OGRE_CURRENT_FUNCTION __func__
#endif

// For marking functions as deprecated
#if __cplusplus >= 201402L || OGRE_COMPILER == OGRE_COMPILER_MSVC && OGRE_COMP_VER >= 1900
# define OGRE_DEPRECATED [[deprecated]]
Expand Down
10 changes: 3 additions & 7 deletions RenderSystems/GL3Plus/include/OgreGL3PlusPrerequisites.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ namespace Ogre
// Convenience macro from ARB_vertex_buffer_object spec
#define GL_BUFFER_OFFSET( i ) reinterpret_cast<void *>( ( i ) )

#if OGRE_COMPILER == OGRE_COMPILER_MSVC
# define __PRETTY_FUNCTION__ __FUNCTION__
#endif

#define ENABLE_GL_CHECK 0
#if ENABLE_GL_CHECK
# include "OgreStringVector.h"
Expand Down Expand Up @@ -141,7 +137,7 @@ namespace Ogre
char msgBuf[4096]; \
StringVector tokens = StringUtil::split( #glFunc, "(" ); \
sprintf( msgBuf, "OpenGL error 0x%04X %s in %s at line %i for %s\n", e, errorString, \
__PRETTY_FUNCTION__, __LINE__, tokens[0].c_str() ); \
OGRE_CURRENT_FUNCTION, __LINE__, tokens[0].c_str() ); \
LogManager::getSingleton().logMessage( msgBuf, LML_CRITICAL ); \
} \
}
Expand All @@ -152,10 +148,10 @@ namespace Ogre
if( ( e != 0 ) && ( e != EGL_SUCCESS ) ) \
{ \
char msgBuf[4096]; \
sprintf( msgBuf, "EGL error 0x%04X in %s at line %i\n", e, __PRETTY_FUNCTION__, \
sprintf( msgBuf, "EGL error 0x%04X in %s at line %i\n", e, OGRE_CURRENT_FUNCTION, \
__LINE__ ); \
LogManager::getSingleton().logMessage( msgBuf ); \
OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, msgBuf, __PRETTY_FUNCTION__ ); \
OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, msgBuf, OGRE_CURRENT_FUNCTION ); \
} \
}
#else
Expand Down
7 changes: 3 additions & 4 deletions RenderSystems/GLES2/include/OgreGLES2Prerequisites.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ THE SOFTWARE.
#else
# if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32)
# if !defined( __MINGW32__ )
# define __PRETTY_FUNCTION__ __FUNCTION__
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN 1
# endif
Expand Down Expand Up @@ -309,7 +308,7 @@ namespace Ogre {
} \
char msgBuf[4096]; \
StringVector tokens = StringUtil::split(#glFunc, "("); \
sprintf(msgBuf, "OpenGL error 0x%04X %s in %s at line %i for %s\n", e, errorString, __PRETTY_FUNCTION__, __LINE__, tokens[0].c_str()); \
sprintf(msgBuf, "OpenGL error 0x%04X %s in %s at line %i for %s\n", e, errorString, OGRE_CURRENT_FUNCTION, __LINE__, tokens[0].c_str()); \
LogManager::getSingleton().logMessage(msgBuf); \
} \
}
Expand All @@ -326,9 +325,9 @@ namespace Ogre {
if ((e != 0) && (e != EGL_SUCCESS))\
{ \
char msgBuf[4096]; \
sprintf(msgBuf, "EGL error 0x%04X in %s at line %i\n", e, __PRETTY_FUNCTION__, __LINE__); \
sprintf(msgBuf, "EGL error 0x%04X in %s at line %i\n", e, OGRE_CURRENT_FUNCTION, __LINE__); \
LogManager::getSingleton().logMessage(msgBuf); \
OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, msgBuf, __PRETTY_FUNCTION__); \
OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, msgBuf, OGRE_CURRENT_FUNCTION); \
} \
}
#else
Expand Down
28 changes: 8 additions & 20 deletions RenderSystems/Vulkan/include/OgreVulkanPrerequisites.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,27 +151,15 @@ namespace Ogre
const char *file, long line );
} // namespace Ogre

#if OGRE_COMPILER == OGRE_COMPILER_MSVC
# define checkVkResult( device, result, functionName ) \
do \
#define checkVkResult( device, result, functionName ) \
do \
{ \
if( result != VK_SUCCESS ) \
{ \
if( result != VK_SUCCESS ) \
{ \
onVulkanFailure( device, result, functionName " failed", __FUNCSIG__, __FILE__, \
__LINE__ ); \
} \
} while( 0 )
#else
# define checkVkResult( device, result, functionName ) \
do \
{ \
if( result != VK_SUCCESS ) \
{ \
onVulkanFailure( device, result, functionName " failed", __PRETTY_FUNCTION__, __FILE__, \
__LINE__ ); \
} \
} while( 0 )
#endif
onVulkanFailure( device, result, functionName " failed", OGRE_CURRENT_FUNCTION, __FILE__, \
__LINE__ ); \
} \
} while( 0 )

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
# if !defined( __MINGW32__ )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,15 @@
#define MY_VK_EXCEPT( code, num, desc, src ) \
OGRE_EXCEPT( code, desc + ( "\nVkResult = " + std::to_string( num ) ), src )

#if OGRE_COMPILER == OGRE_COMPILER_MSVC
# define myCheckVkResult( result, functionName ) \
do \
#define myCheckVkResult( result, functionName ) \
do \
{ \
if( result != VK_SUCCESS ) \
{ \
if( result != VK_SUCCESS ) \
{ \
MY_VK_EXCEPT( Exception::ERR_RENDERINGAPI_ERROR, result, functionName " failed", \
__FUNCSIG__ ); \
} \
} while( 0 )
#else
# define myCheckVkResult( result, functionName ) \
do \
{ \
if( result != VK_SUCCESS ) \
{ \
MY_VK_EXCEPT( Exception::ERR_RENDERINGAPI_ERROR, result, functionName " failed", \
__PRETTY_FUNCTION__ ); \
} \
} while( 0 )
#endif
MY_VK_EXCEPT( Exception::ERR_RENDERINGAPI_ERROR, result, functionName " failed", \
OGRE_CURRENT_FUNCTION ); \
} \
} while( 0 )

/**
@brief createVulkanInstance
Expand Down

0 comments on commit a64b9b6

Please sign in to comment.