-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(bits): move macros to config/macros.h
- Loading branch information
Showing
3 changed files
with
83 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// The MIT License (MIT) | ||
// | ||
// Copyright (c) 2018 Mateusz Pusz | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
#pragma once | ||
|
||
#include <version> | ||
|
||
#if __clang__ | ||
#define UNITS_COMP_CLANG __clang_major__ | ||
#elif __GNUC__ | ||
#define UNITS_COMP_GCC __GNUC__ | ||
#define UNITS_COMP_GCC_MINOR __GNUC_MINOR__ | ||
#elif _MSC_VER | ||
#define UNITS_COMP_MSVC _MSC_VER | ||
#endif | ||
|
||
// Adapted from https://github.com/ericniebler/range-v3/blob/master/include/range/v3/detail/config.hpp#L185. | ||
#define UNITS_PRAGMA(X) _Pragma(#X) | ||
#if !UNITS_COMP_MSVC | ||
#define UNITS_DIAGNOSTIC_PUSH UNITS_PRAGMA(GCC diagnostic push) | ||
#define UNITS_DIAGNOSTIC_POP UNITS_PRAGMA(GCC diagnostic pop) | ||
#define UNITS_DIAGNOSTIC_IGNORE_PRAGMAS UNITS_PRAGMA(GCC diagnostic ignored "-Wpragmas") | ||
#define UNITS_DIAGNOSTIC_IGNORE(X) \ | ||
UNITS_DIAGNOSTIC_IGNORE_PRAGMAS \ | ||
UNITS_PRAGMA(GCC diagnostic ignored "-Wunknown-pragmas") \ | ||
UNITS_PRAGMA(GCC diagnostic ignored "-Wunknown-warning-option") \ | ||
UNITS_PRAGMA(GCC diagnostic ignored X) | ||
#define UNITS_DIAGNOSTIC_IGNORE_EXPR_ALWAYS_TF | ||
#define UNITS_DIAGNOSTIC_IGNORE_LOSS_OF_DATA | ||
#define UNITS_DIAGNOSTIC_IGNORE_MISSING_BRACES UNITS_DIAGNOSTIC_IGNORE("-Wmissing-braces") | ||
#define UNITS_DIAGNOSTIC_IGNORE_NON_TEMPLATE_FRIEND UNITS_DIAGNOSTIC_IGNORE("-Wnon-template-friend") | ||
#define UNITS_DIAGNOSTIC_IGNORE_SHADOW UNITS_DIAGNOSTIC_IGNORE("-Wshadow") | ||
#define UNITS_DIAGNOSTIC_IGNORE_UNREACHABLE | ||
#else | ||
#define UNITS_DIAGNOSTIC_PUSH UNITS_PRAGMA(warning(push)) | ||
#define UNITS_DIAGNOSTIC_POP UNITS_PRAGMA(warning(pop)) | ||
#define UNITS_DIAGNOSTIC_IGNORE_PRAGMAS UNITS_PRAGMA(warning(disable : 4068)) | ||
#define UNITS_DIAGNOSTIC_IGNORE(X) UNITS_DIAGNOSTIC_IGNORE_PRAGMAS UNITS_PRAGMA(warning(disable : X)) | ||
#define UNITS_DIAGNOSTIC_IGNORE_EXPR_ALWAYS_TF UNITS_DIAGNOSTIC_IGNORE(4296) | ||
#define UNITS_DIAGNOSTIC_IGNORE_LOSS_OF_DATA UNITS_DIAGNOSTIC_IGNORE(4244) | ||
#define UNITS_DIAGNOSTIC_IGNORE_MISSING_BRACES | ||
#define UNITS_DIAGNOSTIC_IGNORE_NON_TEMPLATE_FRIEND | ||
#define UNITS_DIAGNOSTIC_IGNORE_SHADOW UNITS_DIAGNOSTIC_IGNORE(4459) | ||
#define UNITS_DIAGNOSTIC_IGNORE_UNREACHABLE UNITS_DIAGNOSTIC_IGNORE(4702) | ||
#endif | ||
|
||
#if _LIBCPP_VERSION | ||
#define UNITS_LIBCXX _LIBCPP_VERSION | ||
#endif | ||
|
||
#if UNITS_COMP_MSVC || UNITS_COMP_CLANG | ||
#define TYPENAME typename | ||
#else | ||
#define TYPENAME | ||
#endif | ||
|
||
#ifdef UNITS_DOWNCAST_MODE | ||
#if UNITS_DOWNCAST_MODE < 0 || UNITS_DOWNCAST_MODE > 2 | ||
#error "Invalid UNITS_DOWNCAST_MODE value" | ||
#endif | ||
#else | ||
#define UNITS_DOWNCAST_MODE 1 | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters