Skip to content

Commit

Permalink
refactor: Optimize common definition module[963011]
Browse files Browse the repository at this point in the history
  • Loading branch information
Greedysky committed Apr 12, 2023
1 parent 6713379 commit 31c4046
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion TTKCommon/TTKLibrary/ttkany.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class TTK_MODULE_EXPORT TTKAny
};

#ifdef TTK_CAST
# define TTKAnyCast(x, y) TTK::any_cast<x>(y)
# define TTKAnyCast(x, y) (TTK::any_cast<x>(y))
#else
# define TTKAnyCast(x, y) ((x)(y))
#endif
Expand Down
34 changes: 31 additions & 3 deletions TTKCommon/ttkglobal.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,34 @@
#include <QVariant>
#include "ttklogger.h"

// Normal definition
#undef TTK_STD_CXX
#define TTK_STD_CXX __cplusplus

// VS2013 - 2015
#if defined Q_CC_MSVC && _MSC_VER >= 1800
#undef TTK_STD_CXX
#define TTK_STD_CXX 201103L
#endif

// VS2017
#if defined Q_CC_MSVC && _MSC_VER >= 1910
#undef TTK_STD_CXX
#define TTK_STD_CXX 201402L
#endif

// VS2019
#if defined Q_CC_MSVC && _MSC_VER >= 1920
#undef TTK_STD_CXX
#define TTK_STD_CXX 201703L
#endif

// VS2022
#if defined Q_CC_MSVC && _MSC_VER >= 1930
#undef TTK_STD_CXX
#define TTK_STD_CXX 202002L
#endif

#ifdef Q_CC_GNU
# pragma GCC diagnostic ignored "-Wswitch"
# pragma GCC diagnostic ignored "-Wparentheses"
Expand Down Expand Up @@ -55,7 +83,7 @@ void qAsConst(const T &&) = delete;
# define TTK_DEBUG
#endif

#if __cplusplus >= 201103L || _MSC_VER > 1800
#if TTK_STD_CXX >= 201103L
# define TTK_CAST
#endif

Expand Down Expand Up @@ -106,7 +134,7 @@ void qAsConst(const T &&) = delete;
#endif

#if !TTK_QT_VERSION_CHECK(5,0,0) && defined(Q_CC_GNU)
# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
# if defined(__GXX_EXPERIMENTAL_CXX0X__) || TTK_STD_CXX >= 201103L
# define Q_COMPILER_DEFAULT_MEMBERS
# define Q_COMPILER_DELETE_MEMBERS
# define Q_COMPILER_NULLPTR
Expand Down Expand Up @@ -146,7 +174,7 @@ void qAsConst(const T &&) = delete;
# endif
#endif

#if defined(Q_CC_MSVC) && _MSC_VER <= 1800
#if defined Q_CC_MSVC && _MSC_VER <= 1800
# define constexpr const
#endif

Expand Down

0 comments on commit 31c4046

Please sign in to comment.