]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/compat.h
Remove the Kiwi links from the readme.
[user/henk/code/inspircd.git] / include / compat.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2013-2014, 2017, 2021 Sadie Powell <sadie@witchery.services>
5  *   Copyright (C) 2013-2014, 2016 Attila Molnar <attilamolnar@hush.com>
6  *
7  * This file is part of InspIRCd.  InspIRCd is free software: you can
8  * redistribute it and/or modify it under the terms of the GNU General Public
9  * License as published by the Free Software Foundation, version 2.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20
21 #pragma once
22
23 /**
24  * Some implementations of the C++11 standard library are incomplete so we use
25  * the implementation of the same types from C++ Technical Report 1 instead.
26  */
27 #if defined _LIBCPP_VERSION || defined _WIN32 || __cplusplus >= 201103L
28 # define TR1NS std
29 # include <array>
30 # include <functional>
31 # include <unordered_map>
32 # include <type_traits>
33 #else
34 # define TR1NS std::tr1
35 # include <tr1/array>
36 # include <tr1/functional>
37 # include <tr1/unordered_map>
38 # include <tr1/type_traits>
39 #endif
40
41 /**
42  * This macro enables the compile-time checking of printf format strings. This
43  * makes the compiler show a warning if the format of a printf arguments are
44  * incorrect.
45  */
46 #if defined __clang__ || defined __GNUC__
47 # define CUSTOM_PRINTF(stringpos, firstpos) __attribute__((format(printf, stringpos, firstpos)))
48 #else
49 # define CUSTOM_PRINTF(stringpos, firstpos)
50 #endif
51
52 /**
53  * These macros enable the use of the C++11 override control keywords in
54  * compilers which support them.
55  */
56 #if __cplusplus >= 201103L
57 # define HAS_CXX11_FINAL_OVERRIDE
58 #elif defined __clang__
59 # if __has_feature(cxx_override_control)
60 #  define HAS_CXX11_FINAL_OVERRIDE
61 # endif
62 #elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
63 # if defined __GXX_EXPERIMENTAL_CXX0X__
64 #  define HAS_CXX11_FINAL_OVERRIDE
65 # endif
66 #elif _MSC_VER >= 1700
67 # define HAS_CXX11_FINAL_OVERRIDE
68 #endif
69
70 #if defined HAS_CXX11_FINAL_OVERRIDE
71 # define CXX11_FINAL final
72 # define CXX11_OVERRIDE override
73 #else
74 # define CXX11_FINAL
75 # define CXX11_OVERRIDE
76 #endif
77
78 /**
79  * This macro allows methods to be marked as deprecated. To use this, wrap the
80  * method declaration in the header file with the macro.
81  */
82 #if defined __clang__ || defined __GNUC__
83 # define DEPRECATED_METHOD(function) function __attribute__((deprecated))
84 #elif defined _MSC_VER
85 # define DEPRECATED_METHOD(function) __declspec(deprecated) function
86 #else
87 # define DEPRECATED_METHOD(function) function
88 #endif
89
90 /**
91  * Windows is very different to UNIX so we have to wrap certain features in
92  * order to build on Windows correctly.
93  */
94 #if defined _WIN32
95 # include "inspircd_win32wrapper.h"
96 # include "threadengines/threadengine_win32.h"
97 #else
98 # define ENTRYPOINT int main(int argc, char** argv)
99 # define DllExport __attribute__ ((visibility ("default")))
100 # define CoreExport __attribute__ ((visibility ("default")))
101 # include <unistd.h>
102 # include "threadengines/threadengine_pthread.h"
103 #endif