TGUI  0.8.9
Config.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2020 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 the SFML config header to check the SFML version
29#include <SFML/Config.hpp>
30
31// Detect the platform, to enable platform-specific code
32#if defined(_WIN32)
33 #define TGUI_SYSTEM_WINDOWS // Windows
34#elif defined(__APPLE__) && defined(__MACH__)
35 #include "TargetConditionals.h"
36 #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
37 #define TGUI_SYSTEM_IOS // iOS
38 #elif TARGET_OS_MAC
39 #define TGUI_SYSTEM_MACOS // macOS
40 #endif
41#elif defined(__unix__)
42 #if defined(__ANDROID__)
43 #define TGUI_SYSTEM_ANDROID // Android
44 #else //if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
45 #define TGUI_SYSTEM_LINUX // Linux or BSD
46 #endif
47#endif
48
49// TGUI will link in the same way as SFML, unless TGUI_DYNAMIC or TGUI_STATIC is defined
50#if !defined(TGUI_DYNAMIC) && !defined(TGUI_STATIC)
51 #ifdef SFML_STATIC
52 #define TGUI_STATIC
53 #endif
54#endif
55
56#ifndef TGUI_STATIC
57 #ifdef TGUI_SYSTEM_WINDOWS
58 // Windows compilers need specific (and different) keywords for export and import
59 #ifdef TGUI_EXPORTS
60 #define TGUI_API __declspec(dllexport)
61 #else
62 #define TGUI_API __declspec(dllimport)
63 #endif
64 #else
65 #define TGUI_API __attribute__ ((__visibility__ ("default")))
66 #endif
67#else
68 // Static build doesn't need import/export macros
69 #define TGUI_API
70 #define TGUI_API
71#endif
72
73
74// Version of the library
75#define TGUI_VERSION_MAJOR 0
76#define TGUI_VERSION_MINOR 8
77#define TGUI_VERSION_PATCH 9
78
79// Define that specifies the mininmum c++ support in both the TGUI code and user code.
80// This constant can be lower than the actual c++ standard version used to compile with,
81// as long as this constant is the same when compiling TGUI and when using the TGUI libs.
82#define TGUI_COMPILED_WITH_CPP_VER 14
83
84// The signal system detects whether it can provide unbound parameters by checking the arguments of the function at runtime.
85// This comparion is made by checking the typeid of the parameters with the typeid of the value which the widget can transmit.
86// Although typeid returns a unique value and the operator== is guarenteed to only be true for the same type, dynamically linked libraries may have a
87// different type_info internally than in the code using the library. In such case the comparison will always be false.
88// This behavior has so far only been seen on android and macOS, so the alternative is currently only used when compiling on these platforms.
89// The alternative that is used is to compare the strings returned by type_info.name(). This is however considered undefined behavior since the compiler
90// 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.
91// I am also not aware of any supported compiler that does not create unique names.
92#if (defined(TGUI_SYSTEM_ANDROID) || defined(TGUI_SYSTEM_MACOS)) && !defined(TGUI_STATIC)
93 #define TGUI_UNSAFE_TYPE_INFO_COMPARISON
94#endif
95
96// Enable the use of std::filesystem if TGUI is built with c++17 with a new enough compiler.
97// Although GCC and clang supported it before version 9, this is the first version where no
98// additional library has to be linked in order to use std::filesystem. This is also the
99// reason why we can't rely on __cpp_lib_filesystem for this.
100#if TGUI_COMPILED_WITH_CPP_VER >= 17
101 #if defined(__clang_major__) && (__clang_major__ >= 9) \
102 || defined(__GNUC__) && (__GNUC___ >= 9) \
103 || defined(_MSC_VER) && (_MSC_VER >= 1914)
104 #define TGUI_USE_STD_FILESYSTEM
105 #endif
106#endif
107
108#if defined(__cpp_constexpr) && (__cpp_constexpr >= 201304L)
109 #define TGUI_CONSTEXPR constexpr
110#else
111 #define TGUI_CONSTEXPR
112#endif
113
114#if __cplusplus >= 201703L
115 #define TGUI_EMPLACE_BACK(object, vector) auto& object = vector.emplace_back();
116#else
117 #define TGUI_EMPLACE_BACK(object, vector) vector.emplace_back(); auto& object = vector.back();
118#endif
119
120#ifndef TGUI_NO_DEPRECATED_WARNINGS
121 #define TGUI_DEPRECATED(msg) [[deprecated(msg)]]
122#else
123 #define TGUI_DEPRECATED(msg)
124#endif
125
126#ifndef TGUI_NO_RUNTIME_WARNINGS
127 #define TGUI_PRINT_WARNING(msg) { sf::err() << "TGUI Warning: " << msg << std::endl; }
128#else
129 #define TGUI_PRINT_WARNING(msg) {}
130#endif
131
132#ifdef TGUI_NEXT
133 #define TGUI_REMOVE_DEPRECATED_CODE
134#endif
135
136// Using [=] gives a warning in c++2a, but using [=,this] may not compile with older c++ versions
137#if __cplusplus > 201703L
138 #define TGUI_LAMBDA_CAPTURE_EQ_THIS [=,this]
139#else
140 #define TGUI_LAMBDA_CAPTURE_EQ_THIS [=]
141#endif
142
143#endif // TGUI_CONFIG_HPP