Skip to content

Commit

Permalink
Refactored RTTI feature detection and moved it to the config header.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrykos committed Nov 7, 2022
1 parent 775e760 commit 95a54b6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 17 deletions.
48 changes: 32 additions & 16 deletions include/CppUTest/CppUTestConfig.h
Expand Up @@ -238,6 +238,17 @@
#endif
#endif

/*
* Detection of run-time type information (RTTI) presence
*/
#ifndef CPPUTEST_HAVE_RTTI
#if defined(_CPPRTTI) || defined(__GXX_RTTI)
#define CPPUTEST_HAVE_RTTI 1
#else
#define CPPUTEST_HAVE_RTTI 0
#endif
#endif

/*
* Detection of different 64 bit environments
*/
Expand Down Expand Up @@ -316,24 +327,29 @@ typedef struct

#endif

#ifdef __cplusplus
/* Visual C++ 10.0+ (2010+) supports the override keyword, but doesn't define the C++ version as C++11 */
#if (__cplusplus >= 201103L) || (defined(_MSC_VER) && (_MSC_VER >= 1600))
#define _override override
#define NULLPTR nullptr
#else
#define _override
#define NULLPTR NULL
#endif
/* Visual C++ 10.0+ (2010+) supports the override keyword, but doesn't define the C++ version as C++11 */
#if defined(__cplusplus) && ((__cplusplus >= 201103L) || (defined(_MSC_VER) && (_MSC_VER >= 1600)))
#if !defined(__ghs__)
#define CPPUTEST_COMPILER_FULLY_SUPPORTS_CXX11
#define _override override
#else
/* GreenHills is not compatible with other compilers with regards to where
* it expects the override specifier to be on methods that return function
* pointers. Given this, it is easiest to not use the override specifier.
*/
#define _override
#endif
#define NULLPTR nullptr
#else
#define _override
#define NULLPTR NULL
#endif

#ifdef __cplusplus
/* Visual C++ 11.0+ (2012+) supports the override keyword on destructors */
#if (__cplusplus >= 201103L) || (defined(_MSC_VER) && (_MSC_VER >= 1700))
#define _destructor_override override
#else
#define _destructor_override
#endif
/* Visual C++ 11.0+ (2012+) supports the override keyword on destructors */
#if defined(__cplusplus) && ((__cplusplus >= 201103L) || (defined(_MSC_VER) && (_MSC_VER >= 1700)))
#define _destructor_override override
#else
#define _destructor_override
#endif

#ifdef __clang__
Expand Down
2 changes: 1 addition & 1 deletion src/CppUTest/TestFailure.cpp
Expand Up @@ -395,7 +395,7 @@ UnexpectedExceptionFailure::UnexpectedExceptionFailure(UtestShell* test)

static SimpleString getExceptionTypeName(const std::exception &e)
{
#if defined(_CPPRTTI) || defined(__GXX_RTTI)
#if CPPUTEST_HAVE_RTTI
const char *name = typeid(e).name();
#if defined(__GNUC__) && (__cplusplus >= 201103L)
int status = -1;
Expand Down

0 comments on commit 95a54b6

Please sign in to comment.