Tulip 5.7.1
Large graphs analysis and drawing
Loading...
Searching...
No Matches
tulipconf.h
1/*
2 *
3 * This file is part of Tulip (https://tulip.labri.fr)
4 *
5 * Authors: David Auber and the Tulip development Team
6 * from LaBRI, University of Bordeaux
7 *
8 * Tulip is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation, either version 3
11 * of the License, or (at your option) any later version.
12 *
13 * Tulip is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
17 *
18 */
19///@cond DOXYGEN_HIDDEN
20
21#ifndef TULIPCONF_H
22#define TULIPCONF_H
23
24#include <cstddef>
25
26/**
27 * @brief this file contains various helper macros and functions to have a true cross-platform
28 * compilation.
29 *
30 */
31
32#define STRINGIFY(PARAM) STRINGIFY_INTERNAL(PARAM)
33#define STRINGIFY_INTERNAL(PARAM) #PARAM
34
35// some useful typedefs
36typedef unsigned int uint;
37typedef unsigned char uchar;
38
39#if defined(_MSC_VER)
40// disable some annoying Visual Studio warnings
41#pragma warning(disable : 4251) // member is not dllexport
42#pragma warning(disable : 4267) // conversion from 'size_t' to 'type', possible loss of data
43#pragma warning(disable : 4275) // base class is not dllexport
44#pragma warning(disable : 4244) // conversion to (or from) smaller integer type
45#pragma warning(disable : 4355) //'this' pointer used in initializer list
46#pragma warning(disable : 4800) // non-bool value coerced into bool (e.g. bool a = 5;)
47#pragma warning(disable : 4503) // decorated name too long, truncated
48#pragma warning(disable : 4344) // template specialisation results in different function being
49 // called (getProperty<>)
50
51// disable deprecated warnings when compiling the tulip dlls, as MSVC is overly verbose with
52// deprecation
53// (even if a deprecated function is not used, warnings are issued)
54#if defined(DLL_TULIP) || defined(DLL_TULIP_GL) || defined(DLL_TULIP_QT) || defined(DLL_TULIP_QT2)
55#pragma warning(disable : 4996) // deprecated functions
56#endif
57
58#define _DEPRECATED __declspec(deprecated)
59#define _DEPRECATED_TYPEDEF(type, deprecated_type) typedef _DEPRECATED type deprecated_type
60
61#define __PRETTY_FUNCTION__ __FUNCTION__ // MSVC has a different name for pretty_function
62#define strcasecmp stricmp // strcasecmp does not exists for VC, workaround
63
64#include <cmath>
65
66inline double fabs(int i) {
67 return std::fabs(double(i));
68}
69
70// Visual Studio 2013 improved C99 support, no need to redefine some cmath functions
71#if _MSC_VER < 1800
72
73// MSVC needs explicit casting of ints to double, float or long double.
74// Let's just pretend he does not.
75#include <cstdlib>
76
77inline double sqrt(int i) {
78 return std::sqrt(double(i));
79}
80
81inline double sqrt(unsigned int i) {
82 return std::sqrt(double(i));
83}
84
85inline double log(int i) {
86 return std::log(double(i));
87}
88
89inline double log(unsigned int i) {
90 return std::log(double(i));
91}
92
93inline double floor(int i) {
94 return std::floor(double(i));
95}
96
97inline double floor(unsigned int i) {
98 return std::floor(double(i));
99}
100
101inline double round(double d) {
102 return std::floor(d + 0.5);
103}
104
105inline float strtof(const char *cptr, char **endptr) {
106 return std::strtod(cptr, endptr);
107}
108
109// C99 features, and VC++ does not support C99. workaround this.
110#define isnan(x) ((x) != (x))
111#define rint(arg) arg > 0 ? int(std::floor(double(arg))) : int(std::ceil(double(arg)))
112
113#if _MSC_VER <= 1600
114inline double log1p(double x) {
115 return log(x + 1);
116}
117#endif
118
119#else // _MSC_VER < 1800
120
121// for std::min and std::max
122#include <algorithm>
123
124#endif // _MSC_VER < 1800
125
126// clang does not define __GNUC_MINOR__, thus having a separate clang #elif seems cleaner than
127// adding defined() in the #else
128#elif __clang__
129#define _DEPRECATED __attribute__((deprecated))
130#define _DEPRECATED_TYPEDEF(type, deprecated_type) typedef type deprecated_type _DEPRECATED
131
132// for GCC 4.X
133#else
134#define _DEPRECATED __attribute__((deprecated))
135#define _DEPRECATED_TYPEDEF(type, deprecated_type) typedef type deprecated_type _DEPRECATED
136#endif
137
138// WIN32 specific defines: dllimport and dllexport stuff
139#ifdef _WIN32
140#ifdef DLL_TULIP
141#define TLP_SCOPE __declspec(dllexport)
142#else
143#define TLP_SCOPE __declspec(dllimport)
144#endif
145#endif
146#ifndef TLP_SCOPE
147#define TLP_SCOPE
148#endif
149
150#ifdef _WIN32
151#ifdef DLL_TULIP_GL
152#define TLP_GL_SCOPE __declspec(dllexport)
153#else
154#define TLP_GL_SCOPE __declspec(dllimport)
155#endif
156#endif
157#ifndef TLP_GL_SCOPE
158#define TLP_GL_SCOPE
159#endif
160
161#ifdef _WIN32
162#ifdef DLL_TULIP_QT
163#define TLP_QT_SCOPE __declspec(dllexport)
164#else
165#define TLP_QT_SCOPE __declspec(dllimport)
166#endif
167#endif
168#ifndef TLP_QT_SCOPE
169#define TLP_QT_SCOPE
170#endif
171
172#ifdef _WIN32
173#ifdef DLL_TULIP_PYTHON
174#define TLP_PYTHON_SCOPE __declspec(dllexport)
175#else
176#define TLP_PYTHON_SCOPE __declspec(dllimport)
177#endif
178#endif
179#ifndef TLP_PYTHON_SCOPE
180#define TLP_PYTHON_SCOPE
181#endif
182
183#include <ostream>
184
185namespace tlp {
186/**
187 *
188 * @brief return the ostream used for the output of debug messages
189 */
190extern TLP_SCOPE std::ostream &debug();
191/**
192 *
193 * @brief set the ostream used for the output debug messages
194 */
195extern TLP_SCOPE void setDebugOutput(std::ostream &os);
196/**
197 *
198 * @brief return the ostream used for the output of warning messages
199 */
200extern TLP_SCOPE std::ostream &warning();
201/**
202 *
203 * @brief set the ostream used for the output of warning messages
204 */
205extern TLP_SCOPE void setWarningOutput(std::ostream &os);
206/**
207 *
208 * @brief allow to enable/disable the output of warning messages
209 */
210extern TLP_SCOPE void enableWarningOutput(bool);
211/**
212 *
213 * @brief indicate if the output of warning messages is enabled
214 */
215extern TLP_SCOPE bool isWarningOutputEnabled();
216/**
217 *
218 * @brief return the ostream used for the output of error messages
219 */
220extern TLP_SCOPE std::ostream &error();
221/**
222 *
223 * @brief set the ostream used for the output of error messages
224 */
225extern TLP_SCOPE void setErrorOutput(std::ostream &os);
226
227/**
228 *
229 * @brief return the TULIP_VERSION value
230 */
231extern TLP_SCOPE std::string getTulipVersion();
232} // namespace tlp
233
234#endif // TULIPCONF_H
235///@endcond