]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/compat.h
Remove unused code from configure.
[user/henk/code/inspircd.git] / include / compat.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2013 Peter Powell <petpow@saberuk.com>
5  *   Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
6  *   Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
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
24 /**
25  * Some implementations of the C++11 standard library are incomplete so we use
26  * the implementation of the same types from C++ Technical Report 1 instead.
27  */
28 #if defined _LIBCPP_VERSION || defined _WIN32
29 # define TR1NS std
30 # include <unordered_map>
31 #else
32 # define TR1NS std::tr1
33 # include <tr1/unordered_map>
34 #endif
35
36 /**
37  * This macro enables the compile-time checking of printf format strings. This
38  * makes the compiler show a warning if the format of a printf arguments are
39  * incorrect.
40  */
41 #if defined __clang__ || defined __GNUC__
42 # define CUSTOM_PRINTF(stringpos, firstpos) __attribute__((format(printf, stringpos, firstpos)))
43 #else
44 # pragma message ("Warning! CUSTOM_PRINTF() does not work on your compiler!")
45 # define CUSTOM_PRINTF(stringpos, firstpos)
46 #endif
47
48 /**
49  * These macros enable the use of the C++11 override control keywords in
50  * compilers which support them.
51  */
52 #if __cplusplus >= 201103L
53 # define HAS_CXX11_FINAL_OVERRIDE
54 #elif defined __clang__
55 # if __has_feature(cxx_override_control)
56 #  define HAS_CXX11_FINAL_OVERRIDE
57 # endif
58 #elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
59 # if defined __GXX_EXPERIMENTAL_CXX0X__
60 #  define HAS_CXX11_FINAL_OVERRIDE
61 # endif
62 #elif _MSC_VER >= 1700
63 # define HAS_CXX11_FINAL_OVERRIDE
64 #endif
65
66 #if defined HAS_CXX11_FINAL_OVERRIDE
67 # define CXX11_FINAL final
68 # define CXX11_OVERRIDE override
69 #else
70 # define CXX11_FINAL
71 # define CXX11_OVERRIDE
72 #endif
73
74 /**
75  * These macros enable the detection of the C++11 variadic templates in
76  * compilers which support them.
77  */
78 #if __cplusplus >= 201103L
79 # define HAS_CXX11_VARIADIC_TEMPLATES
80 #elif defined __clang__
81 # if __has_feature(cxx_variadic_templates)
82 #  define HAS_CXX11_VARIADIC_TEMPLATES
83 # endif
84 #elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
85 # if defined __GXX_EXPERIMENTAL_CXX0X__
86 #  define HAS_CXX11_VARIADIC_TEMPLATES
87 # endif
88 #elif _MSC_FULL_VER >= 170051025
89 # define HAS_CXX11_VARIADIC_TEMPLATES
90 #endif
91
92 /**
93  * This macro allows methods to be marked as deprecated. To use this, wrap the
94  * method declaration in the header file with the macro.
95  */
96 #if defined __clang__ || defined __GNUC__
97 # define DEPRECATED_METHOD(function) function __attribute__((deprecated))
98 #elif defined _MSC_VER
99 # define DEPRECATED_METHOD(function) __declspec(deprecated) function
100 #else
101 # pragma message ("Warning! DEPRECATED_METHOD() does not work on your compiler!")
102 # define DEPRECATED_METHOD(function) function
103 #endif
104
105 /**
106  * Windows is very different to UNIX so we have to wrap certain features in
107  * order to build on Windows correctly.
108  */
109 #if defined _WIN32
110 # include "inspircd_win32wrapper.h"
111 #else
112 # include <unistd.h>
113 # define ENTRYPOINT int main(int argc, char** argv)
114 # define DllExport
115 # define CoreExport
116 #endif