Tulip  4.0.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
tulipconf.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
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 #include <QtCore/QDebug>
24 
25 /**
26  * @brief this file contains various helper macros and functions to have a true cross-platform compilation.
27  *
28  */
29 
30 #define STRINGIFY(PARAM) STRINGIFY_INTERNAL(PARAM)
31 #define STRINGIFY_INTERNAL(PARAM) #PARAM
32 
33 //MSVC and GCC in c++11 mode use decltype instead of typeof
34 #if !defined(_MSC_VER)
35 # if defined(__GXX_EXPERIMENTAL_CXX0X__)
36 # define TYPEOF decltype
37 # else
38 # define TYPEOF typeof
39 # endif
40 #endif
41 
42 #if defined(_MSC_VER)
43 // disable some annoying Visual Studio warnings
44 #pragma warning(disable: 4251) //member is not dllexport
45 #pragma warning(disable: 4275) //base class is not dllexport
46 #pragma warning(disable: 4244) //conversion to (or from) smaller integer type
47 #pragma warning(disable: 4355) //'this' pointer used in initializer list
48 #pragma warning(disable: 4800) //non-bool value coerced into bool (e.g. bool a = 5;)
49 #pragma warning(disable: 4503) //decorated name too long, truncated
50 #pragma warning(disable: 4344) //template specialisation results in different function being called (getProperty<>)
51 // disable deprecated warnings when compiling the tulip dlls, as MSVC is overly verbose with deprecation
52 // (even if a deprecated function is not used, warnings are issued)
53 #if defined(DLL_TULIP) || defined(DLL_TULIP_GL) || defined(DLL_TULIP_QT) || defined(DLL_TULIP_QT2)
54 #pragma warning(disable: 4996) //deprecated functions
55 #endif
56 //MSVC 2010 has a different keyword for typeof, and deprecated
57 # if _MSC_VER >= 1600
58 # define _DEPRECATED __declspec(deprecated)
59 # define TYPEOF decltype
60 # else
61 //MSVC 2008 must use Boost's typeof
62 # include "boost/typeof/typeof.hpp"
63 # define TYPEOF BOOST_TYPEOF
64 # endif
65 
66 //MSVC needs explicit casting of ints ot double, float or long double. Let's just pretend he does not.
67 #include <math.h>
68 static double sqrt(int i) {
69  return sqrt((double)i);
70 }
71 static double sqrt(unsigned int i) {
72  return sqrt((double)i);
73 }
74 
75 static double log(int i) {
76  return log((double)i);
77 }
78 static double log(unsigned int i) {
79  return log((double)i);
80 }
81 
82 static double floor(int i) {
83  return floor((double)i);
84 }
85 static double floor(unsigned int i) {
86  return floor((double)i);
87 }
88 
89 static double round(double d) {
90  return floor(d + 0.5);
91 }
92 
93 static double fabs(int i) {
94  return fabs((double)i);
95 }
96 
97 static float strtof(const char* cptr, char** endptr) {
98  return strtod(cptr, endptr);
99 }
100 
101 # define __PRETTY_FUNCTION__ __FUNCTION__ //MSVC has a different name for pretty_function
102 # define strcasecmp stricmp //strcasecmp does not exists for VC, workaround
103 # define cbrt(arg) pow((double)arg, 1.0/3) //VC does not have cbrt, little workaround
104 # define isnan(x) ((x) != (x)) //you guessed it, this is a C99 feature, and VC++ does not support C99. workaroud this.
105 # define rint(arg) arg > 0 ? (int)std::floor((double)arg) : (int)std::ceil((double)arg) //Hey, nother C99 feature !
106 
107 //for GCC 3.X
108 #elif (__GNUC__ < 3)
109 # define stdext std
110 # define _DEPRECATED
111 # include <stl_hash_fun.h>
112 
113 //clang does not define __GNUC_MINOR__, thus having a separate clang #elif seems cleaner than adding defined() in the #else
114 #elif __clang__
115 # define _DEPRECATED __attribute__ ((deprecated))
116 # define stdext __gnu_cxx
117 
118 //for GCC 4.X
119 #else
120 # define _DEPRECATED __attribute__ ((deprecated))
121 # define stdext __gnu_cxx
122 # if (__GNUC_MINOR__ < 4 && __GNUC__ < 4)
123 # include <ext/stl_hash_fun.h>
124 # elif (__GNUC_MINOR__ < 3)
125 # include <ext/hash_fun.h>
126 # endif
127 #endif
128 
129 //WIN32 specific defines: dllimport and dllexport stuff
130 #ifdef _WIN32
131 # ifdef DLL_TULIP
132 # define TLP_SCOPE __declspec(dllexport)
133 # else
134 # define TLP_SCOPE __declspec(dllimport)
135 # endif
136 #endif
137 #ifndef TLP_SCOPE
138 # define TLP_SCOPE
139 #endif
140 
141 #ifdef _WIN32
142 # ifdef DLL_TULIP_GL
143 # define TLP_GL_SCOPE __declspec(dllexport)
144 # else
145 # define TLP_GL_SCOPE __declspec(dllimport)
146 # endif
147 #endif
148 #ifndef TLP_GL_SCOPE
149 # define TLP_GL_SCOPE
150 #endif
151 
152 #ifdef _WIN32
153 # ifdef DLL_TULIP_QT
154 # define TLP_QT_SCOPE __declspec(dllexport)
155 # else
156 # define TLP_QT_SCOPE __declspec(dllimport)
157 # endif
158 #endif
159 #ifndef TLP_QT_SCOPE
160 # define TLP_QT_SCOPE
161 #endif
162 
163 #ifdef _WIN32
164 # ifdef DLL_TULIP_OGDF
165 # define TLP_OGDF_SCOPE __declspec(dllexport)
166 # else
167 # define TLP_OGDF_SCOPE __declspec(dllimport)
168 # endif
169 #endif
170 #ifndef TLP_OGDF_SCOPE
171 # define TLP_OGDF_SCOPE
172 #endif
173 
174 QDebug TLP_SCOPE operator<<(QDebug,const std::string&);
175 
176 #endif //TULIPCONF_H
177 ///@endcond