1/*
2 * Copyright (c) 2010-2017 OTClient <https://github.com/edubart/otclient>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 */
22
23#ifndef STDEXT_COMPILER_H
24#define STDEXT_COMPILER_H
25
26#ifdef WIN32
27#include <winsock2.h>
28#endif
29
30#ifdef __clang__
31 // clang is supported
32 #define BUILD_COMPILER "clang " __VERSION__
33#elif defined(__GNUC__)
34 #if !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
35 #error "Sorry, you need gcc 4.6 or greater to compile."
36 #endif
37 #define BUILD_COMPILER "gcc " __VERSION__
38#elif defined(_MSC_VER)
39 #if _MSC_VER < 1800
40 #error "You need Visual Studio 2013 or greater to compile."
41 #endif
42 #pragma warning(disable:4244) // conversion from 'A' to 'B', possible loss of data
43 #pragma warning(disable:4267) // '?' : conversion from 'A' to 'B', possible loss of data
44 #pragma warning(disable:4305) // 'initializing' : truncation from 'A' to 'B'
45 #pragma warning(disable:4146) // unary minus operator applied to unsigned type, result still unsigned
46 #pragma warning(disable:4800) // 'A' : forcing value to bool 'true' or 'false' (performance warning)
47 #pragma warning(disable:4996) // depracated warning as error
48
49 #if _MSC_VER == 1912 || _MSC_VER == 1911 || _MSC_VER == 1910
50 #define BUILD_COMPILER "Visual Studio 2017"
51 #elif _MSC_VER == 1900
52 #define BUILD_COMPILER "Visual Studio 2015"
53 #elif _MSC_VER == 1800
54 #define BUILD_COMPILER "Visual Studio 2013"
55 #else
56 #define BUILD_COMPILER "Visual Studio"
57 #endif
58
59 #define __PRETTY_FUNCTION__ __FUNCDNAME__
60#else
61 #error "Compiler not supported."
62#endif
63
64/// Branch Prediction. See the GCC Manual for more information.
65/// NB: These are used when speed is need most; do not use in normal
66/// code, they may slow down stuff.
67#if defined(__clang__) || defined(__GNUC__)
68#define likely(x) __builtin_expect(!!(x), 1)
69#define unlikely(x) __builtin_expect(!!(x), 0)
70#else
71#define likely(x) (x)
72#define unlikely(x) (x)
73#endif
74
75#if !defined(_MSC_VER) && !defined(__GXX_EXPERIMENTAL_CXX0X__)
76#error "C++0x is required to compile this application. Try updating your compiler."
77#endif
78
79#endif
80