From de53b1f4aeadf680e0fa8e6606b725dab0182231 Mon Sep 17 00:00:00 2001 From: Edouard A Date: Sun, 8 May 2016 10:51:06 +0200 Subject: [PATCH] Issue #146 - First version of compiler detection macros --- CMakeLists.txt | 2 ++ brigand/config.hpp | 21 +++++++++++++++++++++ test/config_test.cpp | 14 ++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 brigand/config.hpp create mode 100644 test/config_test.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ef2c55..0c4e878 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,6 +48,7 @@ set(BRIGAND_GROUP brigand/adapted.hpp brigand/algorithms.hpp brigand/brigand.hpp + brigand/config.hpp brigand/functions.hpp brigand/sequences.hpp brigand/types.hpp @@ -228,6 +229,7 @@ set(test_files test/bind.cpp test/bitwise_test.cpp test/comparison_test.cpp + test/config_test.cpp test/eval_if_test.cpp test/erase_c_test.cpp test/find.cpp diff --git a/brigand/config.hpp b/brigand/config.hpp new file mode 100644 index 0000000..a006496 --- /dev/null +++ b/brigand/config.hpp @@ -0,0 +1,21 @@ +/*================================================================================================== +Copyright (c) 2015 Edouard Alligand and Joel Falcou + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) +=================================================================================================**/ +#pragma once + +// configuration macros for brigand + +#ifdef _MSC_VER +#define BRIGAND_COMP_MSVC +#endif + +#ifdef __GNUC__ +#ifndef __clang__ +#define BRIGAND_COMP_GCC +#else +#define BRIGAND_COMP_CLANG +#endif +#endif diff --git a/test/config_test.cpp b/test/config_test.cpp new file mode 100644 index 0000000..685cfa2 --- /dev/null +++ b/test/config_test.cpp @@ -0,0 +1,14 @@ + +#include + +#ifdef BRIGAND_COMP_MSVC +static_assert(_MSC_VER > 0, "wrong compiler detection macro"); +#endif + +#ifdef BRIGAND_COMP_GCC +static_assert(__GNUC__ > 0, "wrong compiler detection macro"); +#endif + +#ifdef BRIGAND_COMP_CLANG +static_assert(__clang__ > 0, "wrong compiler detection macro"); +#endif