jeaiii / ce

Common Environment for c++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add compiler macros

jeaiii opened this issue · comments

example

#define CE_VERSION(MAJOR, MINOR, PATCH) (((((MAJOR) * 100000) + (MINOR)) * 100000) + (PATCH))

#if !defined(CE_ON_CLANG) && defined(__clang__)
#define CE_ON_CLANG CE_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__)
#else
#define CE_ON_CLANG 0
#endif

#if !defined(CE_ON_MSVC) && defined(_MSC_FULL_VER)
#define CE_ON_MSVC CE_VERSION(_MSC_FULL_VER / 10000000, _MSC_FULL_VER / 100000 % 100, _MSC_FULL_VER % 100000)
#else
#define CE_ON_MSVC 0
#endif

#if !defined(CE_ON_GCC) && defined(__GNUC__)
#define CE_ON_GCC CE_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
#else
#define CE_ON_GCC 0 
#endif

#define _CE_ON_CLANG CE_ON_CLANG && CE_ON_CLANG
#define _CE_ON_MSVC CE_ON_MSVC && CE_ON_MSVC
#define _CE_ON_GCC CE_ON_GCC && CE_ON_GCC

#define CE_IS_ON(WHAT) _CE_ON_ ## WHAT

#if CE_IS_ON(GCC < CE_VERSION(15, 0, 0))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmultichar"
#endif