Commit 4781c75f authored by Dominik Charousset's avatar Dominik Charousset

Add new `CAF_COMPILER_VERSION` convenience macro

parent 6ffdb814
...@@ -30,16 +30,37 @@ ...@@ -30,16 +30,37 @@
// to complete traces (4) // to complete traces (4)
/** /**
* Denotes the libcaf version in the format {MAJOR}{MINOR}{PATCH}, * Denotes version of CAF in the format {MAJOR}{MINOR}{PATCH},
* whereas each number is a two-digit decimal number without * whereas each number is a two-digit decimal number without
* leading zeros (e.g. 900 is version 0.9.0). * leading zeros (e.g. 900 is version 0.9.0).
*/ */
#define CAF_VERSION 1300 #define CAF_VERSION 1300
/**
* Defined to the major version number of CAF.
**/
#define CAF_MAJOR_VERSION (CAF_VERSION / 10000) #define CAF_MAJOR_VERSION (CAF_VERSION / 10000)
/**
* Defined to the minor version number of CAF.
**/
#define CAF_MINOR_VERSION ((CAF_VERSION / 100) % 100) #define CAF_MINOR_VERSION ((CAF_VERSION / 100) % 100)
/**
* Defined to the patch version number of CAF.
**/
#define CAF_PATCH_VERSION (CAF_VERSION % 100) #define CAF_PATCH_VERSION (CAF_VERSION % 100)
// This compiler-specific block defines:
// - CAF_DEPRECATED to annotate deprecated functions
// - CAF_PUSH_WARNINGS/CAF_POP_WARNINGS to surround "noisy" header includes
// - CAF_ANNOTATE_FALLTHROUGH to suppress warnings in switch/case statements
// - CAF_COMPILER_VERSION to retrieve the compiler version in CAF_VERSION format
// - One of the following:
// + CAF_CLANG
// + CAF_GCC
// + CAF_MSVC
// sets CAF_DEPRECATED, CAF_ANNOTATE_FALLTHROUGH, // sets CAF_DEPRECATED, CAF_ANNOTATE_FALLTHROUGH,
// CAF_PUSH_WARNINGS and CAF_POP_WARNINGS // CAF_PUSH_WARNINGS and CAF_POP_WARNINGS
#if defined(__clang__) #if defined(__clang__)
...@@ -76,18 +97,23 @@ ...@@ -76,18 +97,23 @@
# define CAF_POP_WARNINGS \ # define CAF_POP_WARNINGS \
_Pragma("clang diagnostic pop") _Pragma("clang diagnostic pop")
# define CAF_ANNOTATE_FALLTHROUGH [[clang::fallthrough]] # define CAF_ANNOTATE_FALLTHROUGH [[clang::fallthrough]]
# define CAF_COMPILER_VERSION \
(__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
#elif defined(__GNUC__) #elif defined(__GNUC__)
# define CAF_GCC # define CAF_GCC
# define CAF_DEPRECATED __attribute__((__deprecated__)) # define CAF_DEPRECATED __attribute__((__deprecated__))
# define CAF_PUSH_WARNINGS # define CAF_PUSH_WARNINGS
# define CAF_POP_WARNINGS # define CAF_POP_WARNINGS
# define CAF_ANNOTATE_FALLTHROUGH static_cast<void>(0) # define CAF_ANNOTATE_FALLTHROUGH static_cast<void>(0)
# define CAF_COMPILER_VERSION \
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
# define CAF_MSVC # define CAF_MSVC
# define CAF_DEPRECATED # define CAF_DEPRECATED
# define CAF_PUSH_WARNINGS # define CAF_PUSH_WARNINGS
# define CAF_POP_WARNINGS # define CAF_POP_WARNINGS
# define CAF_ANNOTATE_FALLTHROUGH static_cast<void>(0) # define CAF_ANNOTATE_FALLTHROUGH static_cast<void>(0)
# define CAF_COMPILER_VERSION _MSC_FULL_VER
#else #else
# define CAF_DEPRECATED # define CAF_DEPRECATED
# define CAF_PUSH_WARNINGS # define CAF_PUSH_WARNINGS
...@@ -95,7 +121,12 @@ ...@@ -95,7 +121,12 @@
# define CAF_ANNOTATE_FALLTHROUGH static_cast<void>(0) # define CAF_ANNOTATE_FALLTHROUGH static_cast<void>(0)
#endif #endif
// detect OS // This OS-specific block defines one of the following:
// - CAF_MACOS
// - CAF_LINUX
// - CAF_BSD
// - CAF_WINDOWS
// It also defines CAF_POSIX for POSIX-compatible systems
#if defined(__APPLE__) #if defined(__APPLE__)
# define CAF_MACOS # define CAF_MACOS
# ifndef _GLIBCXX_HAS_GTHREADS # ifndef _GLIBCXX_HAS_GTHREADS
...@@ -121,7 +152,7 @@ ...@@ -121,7 +152,7 @@
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
// import backtrace and backtrace_symbols_fd into caf::detail // Optionally enable CAF_ASSERT
#ifndef CAF_ENABLE_RUNTIME_CHECKS #ifndef CAF_ENABLE_RUNTIME_CHECKS
# define CAF_ASSERT(unused) static_cast<void>(0) # define CAF_ASSERT(unused) static_cast<void>(0)
#elif defined(CAF_WINDOWS) || defined(CAF_BSD) #elif defined(CAF_WINDOWS) || defined(CAF_BSD)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment