TGUI  0.8-dev
Config.hpp
1 //
3 // TGUI - Texus' Graphical User Interface
4 // Copyright (C) 2012-2017 Bruno Van de Velde (vdv_b@tgui.eu)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24 
25 #ifndef TGUI_CONFIG_HPP
26 #define TGUI_CONFIG_HPP
27 
28 #include <SFML/Config.hpp>
29 
30 // TGUI will link in the same way as SFML, unless TGUI_DYNAMIC or TGUI_STATIC is defined
31 #if !defined(TGUI_DYNAMIC) && !defined(TGUI_STATIC)
32  #ifdef SFML_STATIC
33  #define TGUI_STATIC
34  #endif
35 #endif
36 
37 #ifndef TGUI_STATIC
38 
39  #ifdef SFML_SYSTEM_WINDOWS
40 
41  // Windows compilers need specific (and different) keywords for export and import
42  #ifdef tgui_EXPORTS
43  #define TGUI_API __declspec(dllexport)
44  #else
45  #define TGUI_API __declspec(dllimport)
46  #endif
47 
48  #else // Linux, FreeBSD, Mac OS X
49 
50  // GCC 4 has special keywords for showing/hidding symbols
51  #if __GNUC__ >= 4
52  #define TGUI_API __attribute__ ((__visibility__ ("default")))
53  #else
54  #define TGUI_API
55  #endif
56 
57  #endif
58 
59 #else
60 
61  // Static build doesn't need import/export macros
62  #define TGUI_API
63  #define TGUI_API
64 
65 #endif
66 
67 
68 // Version of the library
69 #define TGUI_VERSION_MAJOR 0
70 #define TGUI_VERSION_MINOR 8
71 #define TGUI_VERSION_PATCH 0
72 
73 // Disable c++14 code when using -std=c++11, which is needed for android when using NDK 12b.
74 // This technically results in undefined behavior because the std::function ambiguity was only fixed in c++14 (http://cplusplus.github.io/LWG/lwg-defects.html#2132).
75 // TGUI relies on a fix for LWG 2132 to be implemented, even when compiling with -std=c++11 (which is the case in supported gcc and clang compilers).
76 // The TGUI_NO_CPP14 macro thus does not provide support for all compilers with c++11 support, it just allows some compilers to work even with -std=c++11.
77 #ifndef _MSC_VER
78  #if __cplusplus <= 201103L
79  #define TGUI_NO_CPP14
80  #endif
81 #endif
82 
83 // The signal system detects whether it can provide unbound parameters by checking the arguments of the function at runtime.
84 // This comparion is made by checking the typeid of the parameters with the typeid of the value which the widget can transmit.
85 // Although typeid returns a unique value and the operator== is guarenteed to only be true for the same type, it may not always work correctly.
86 // Dynamically linked libraries may have a different type_info internally than in the code using the library. In such case the comparison will always be false.
87 // This behavior has so far only been seen on android (using NDK 12b), so the alternative is currently only used when compiling on android.
88 // The alternative that is used on android is to compare the strings returned by type_info.name(). This is however considered undefined behavior since the compiler
89 // is not guarenteed to have unique names for different types. The names will however be the same inside and outside the library so this method solves the issue.
90 // I am also not aware of any supported compiler that does not create unique names.
91 #ifdef __ANDROID__
92  #define TGUI_UNSAFE_TYPE_INFO_COMPARISON
93 #endif
94 
95 // Enable constexpr when using Clang or at least GCC 5 or MSVC++ 14.1 (VS2017)
96 #if defined(_MSC_VER)
97  #if _MSC_VER >= 1910
98  #define TGUI_CONSTEXPR constexpr
99  #else
100  #define TGUI_CONSTEXPR
101  #endif
102 #elif defined(__GNUC__)
103  #if __cpp_constexpr >= 201304
104  #define TGUI_CONSTEXPR constexpr
105  #else
106  #define TGUI_CONSTEXPR
107  #endif
108 #else
109  #define TGUI_CONSTEXPR constexpr
110 #endif
111 
112 #ifndef TGUI_NO_DEPRECATED_WARNINGS
113  #define TGUI_DEPRECATED(msg) [[deprecated(msg)]]
114 #endif
115 
116 #endif // TGUI_CONFIG_HPP