Loading...
Searching...
No Matches
compiler.hpp
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 *
3 * bitpit
4 *
5 * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6 *
7 * -------------------------------------------------------------------------
8 * License
9 * This file is part of bitpit.
10 *
11 * bitpit is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License v3 (LGPL)
13 * as published by the Free Software Foundation.
14 *
15 * bitpit is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with bitpit. If not, see <http://www.gnu.org/licenses/>.
22 *
23 \*---------------------------------------------------------------------------*/
24
25#ifndef __BITPIT_COMPILER_HPP__
26#define __BITPIT_COMPILER_HPP__
27
40#ifdef BITPIT_ENABLE_BUILTIN_UNREACHABLE
41#define BITPIT_UNREACHABLE(str) \
42do { \
43 assert(!str); \
44 __builtin_unreachable(); \
45} while (0)
46#elif defined (_MSC_VER)
47#define BITPIT_UNREACHABLE(str) \
48do { \
49 assert(!str); \
50 __assume(0); \
51} while (0)
52#else
53#define BITPIT_UNREACHABLE(str) assert(!str)
54#endif
55
63#define BITPIT_UNUSED(variable) \
64do { \
65 (void)(variable); \
66} while (0)
67
68
76#if defined __GNUC__
77# define BITPIT_DEPRECATED(func) func __attribute__ ((deprecated))
78# define BITPIT_DEPRECATED_FOR(func, replacement) func __attribute__ ((deprecated(" Use " #replacement)))
79#elif defined __clang__
80# define BITPIT_DEPRECATED(func) func __attribute__ ((deprecated))
81# define BITPIT_DEPRECATED_FOR(func, replacement) func __attribute__ ((deprecated(" Use " #replacement)))
82#elif defined(_MSC_VER)
83# define BITPIT_DEPRECATED(func) __declspec(deprecated) func
84# define BITPIT_DEPRECATED_FOR(func, replacement) __declspec(deprecated(" Use " #replacement)) func
85#else
86# pragma message("WARNING: macros to declare functions as deprecated are not implemented for this compiler")
87# define BITPIT_DEPRECATED(func) func
88# define BITPIT_DEPRECATED_FOR(func, replacement) func
89#endif
90
91
97#define BITPIT_COMMA ,
98
99
105#if __cplusplus < 201703L
106template <class...>
107struct make_void { using type = void; };
108
109template <typename... T>
110using void_t = typename make_void<T...>::type;
111
112template <typename... T>
113using bitpit_void_t = void_t<T...>;
114#else
115template <typename... T>
116using bitpit_void_t = std::void_t<T...>;
117#endif
118
119#endif
--- layout: doxygen_footer ---