InspIRCd  3.0
compat.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  * Copyright (C) 2013 Peter Powell <[email protected]>
5  * Copyright (C) 2008 Thomas Stagner <[email protected]>
6  * Copyright (C) 2007 Robin Burchell <[email protected]>
7  *
8  * This file is part of InspIRCd. InspIRCd is free software: you can
9  * redistribute it and/or modify it under the terms of the GNU General Public
10  * License as published by the Free Software Foundation, version 2.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 
22 #pragma once
23 
28 #if defined _LIBCPP_VERSION || defined _WIN32
29 # define TR1NS std
30 # include <array>
31 # include <unordered_map>
32 # include <type_traits>
33 #else
34 # define TR1NS std::tr1
35 # include <tr1/array>
36 # include <tr1/unordered_map>
37 # include <tr1/type_traits>
38 #endif
39 
45 #if defined __clang__ || defined __GNUC__
46 # define CUSTOM_PRINTF(stringpos, firstpos) __attribute__((format(printf, stringpos, firstpos)))
47 #else
48 # define CUSTOM_PRINTF(stringpos, firstpos)
49 #endif
50 
55 #if __cplusplus >= 201103L
56 # define HAS_CXX11_FINAL_OVERRIDE
57 #elif defined __clang__
58 # if __has_feature(cxx_override_control)
59 # define HAS_CXX11_FINAL_OVERRIDE
60 # endif
61 #elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
62 # if defined __GXX_EXPERIMENTAL_CXX0X__
63 # define HAS_CXX11_FINAL_OVERRIDE
64 # endif
65 #elif _MSC_VER >= 1700
66 # define HAS_CXX11_FINAL_OVERRIDE
67 #endif
68 
69 #if defined HAS_CXX11_FINAL_OVERRIDE
70 # define CXX11_FINAL final
71 # define CXX11_OVERRIDE override
72 #else
73 # define CXX11_FINAL
74 # define CXX11_OVERRIDE
75 #endif
76 
81 #if __cplusplus >= 201103L
82 # define HAS_CXX11_VARIADIC_TEMPLATES
83 #elif defined __clang__
84 # if __has_feature(cxx_variadic_templates)
85 # define HAS_CXX11_VARIADIC_TEMPLATES
86 # endif
87 #elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
88 # if defined __GXX_EXPERIMENTAL_CXX0X__
89 # define HAS_CXX11_VARIADIC_TEMPLATES
90 # endif
91 #elif _MSC_FULL_VER >= 170051025
92 # define HAS_CXX11_VARIADIC_TEMPLATES
93 #endif
94 
99 #if defined __clang__ || defined __GNUC__
100 # define DEPRECATED_METHOD(function) function __attribute__((deprecated))
101 #elif defined _MSC_VER
102 # define DEPRECATED_METHOD(function) __declspec(deprecated) function
103 #else
104 # define DEPRECATED_METHOD(function) function
105 #endif
106 
111 #if defined _WIN32
112 # include "inspircd_win32wrapper.h"
113 # include "threadengines/threadengine_win32.h"
114 #else
115 # define ENTRYPOINT int main(int argc, char** argv)
116 # define DllExport __attribute__ ((visibility ("default")))
117 # define CoreExport __attribute__ ((visibility ("default")))
118 # include <unistd.h>
119 # include "threadengines/threadengine_pthread.h"
120 #endif