Tulip  4.6.0
Better Visualization Through Research
library/tulip-core/include/tulip/tulipconf.h
00001 /*
00002  *
00003  * This file is part of Tulip (www.tulip-software.org)
00004  *
00005  * Authors: David Auber and the Tulip development Team
00006  * from LaBRI, University of Bordeaux
00007  *
00008  * Tulip is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License
00010  * as published by the Free Software Foundation, either version 3
00011  * of the License, or (at your option) any later version.
00012  *
00013  * Tulip is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  * See the GNU General Public License for more details.
00017  *
00018  */
00019 ///@cond DOXYGEN_HIDDEN
00020 
00021 #ifndef TULIPCONF_H
00022 #define TULIPCONF_H
00023 
00024 /**
00025  * @brief this file contains various helper macros and functions to have a true cross-platform compilation.
00026  *
00027  */
00028 
00029 #define STRINGIFY(PARAM) STRINGIFY_INTERNAL(PARAM)
00030 #define STRINGIFY_INTERNAL(PARAM) #PARAM
00031 
00032 //MSVC and GCC in c++11 mode use decltype instead of typeof
00033 #if !defined(_MSC_VER)
00034 #  if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
00035 #    define TYPEOF decltype
00036 #  else
00037 #    define TYPEOF typeof
00038 #  endif
00039 #endif
00040 
00041 #if defined(_MSC_VER)
00042 // disable some annoying Visual Studio warnings
00043 #pragma warning(disable: 4251) //member is not dllexport
00044 #pragma warning(disable: 4267) //conversion from 'size_t' to 'type', possible loss of data
00045 #pragma warning(disable: 4275) //base class is not dllexport
00046 #pragma warning(disable: 4244) //conversion to (or from) smaller integer type
00047 #pragma warning(disable: 4355) //'this' pointer used in initializer list
00048 #pragma warning(disable: 4800) //non-bool value coerced into bool (e.g. bool a = 5;)
00049 #pragma warning(disable: 4503) //decorated name too long, truncated
00050 #pragma warning(disable: 4344) //template specialisation results in different function being called (getProperty<>)
00051 
00052 // disable deprecated warnings when compiling the tulip dlls, as MSVC is overly verbose with deprecation
00053 // (even if a deprecated function is not used, warnings are issued)
00054 #if defined(DLL_TULIP) || defined(DLL_TULIP_GL) || defined(DLL_TULIP_QT) || defined(DLL_TULIP_QT2)
00055 #pragma warning(disable: 4996) //deprecated functions
00056 #endif
00057 
00058 //MSVC 2010 has a different keyword for typeof, and deprecated
00059 #  if _MSC_VER >= 1600
00060 #    define _DEPRECATED __declspec(deprecated)
00061 #    define _DEPRECATED_TYPEDEF(type, deprecated_type) typedef _DEPRECATED type deprecated_type
00062 #    define TYPEOF decltype
00063 #  else
00064 //MSVC 2008 must use Boost's typeof
00065 #    include "boost/typeof/typeof.hpp"
00066 #    define TYPEOF BOOST_TYPEOF
00067 #  endif
00068 
00069 #  define __PRETTY_FUNCTION__ __FUNCTION__ //MSVC has a different name for pretty_function
00070 #  define strcasecmp stricmp  //strcasecmp does not exists for VC, workaround
00071 
00072 #include <cmath>
00073 
00074 static double fabs(int i) {
00075   return std::fabs(static_cast<double>(i));
00076 }
00077 
00078 #  if _MSC_VER < 1800 // Visual Studio 2013 improved C99 support, no need to redefine some cmath functions
00079 
00080 // MSVC needs explicit casting of ints ot double, float or long double. Let's just pretend he does not.
00081 #include <cstdlib>
00082 
00083 static double sqrt(int i) {
00084   return std::sqrt(static_cast<double>(i));
00085 }
00086 
00087 static double sqrt(unsigned int i) {
00088   return std::sqrt(static_cast<double>(i));
00089 }
00090 
00091 static double log(int i) {
00092   return std::log(static_cast<double>(i));
00093 }
00094 
00095 static double log(unsigned int i) {
00096   return std::log(static_cast<double>(i));
00097 }
00098 
00099 static double floor(int i) {
00100   return std::floor(static_cast<double>(i));
00101 }
00102 
00103 static double floor(unsigned int i) {
00104   return std::floor(static_cast<double>(i));
00105 }
00106 
00107 static double round(double d) {
00108   return std::floor(d + 0.5);
00109 }
00110 
00111 static float strtof(const char* cptr, char** endptr) {
00112   return std::strtod(cptr, endptr);
00113 }
00114 
00115 #define isnan(x) ((x) != (x)) //you guessed it, this is a C99 feature, and VC++ does not support C99. workaroud this.
00116 #define rint(arg) arg > 0 ? static_cast<int>(std::floor(static_cast<double>(arg))) : static_cast<int>(std::ceil(static_cast<double>(arg))) //Hey, nother C99 feature !
00117 
00118 #  else // _MSC_VER < 1800
00119 
00120 // for std::min and std::max
00121 #include <algorithm>
00122 
00123 #  endif // _MSC_VER < 1800
00124 
00125 //clang does not define __GNUC_MINOR__, thus having a separate clang #elif seems cleaner than adding defined() in the #else
00126 #elif __clang__
00127 #  define _DEPRECATED __attribute__ ((deprecated))
00128 #  define _DEPRECATED_TYPEDEF(type, deprecated_type) typedef type deprecated_type _DEPRECATED
00129 #  define stdext __gnu_cxx
00130 
00131 //for GCC 4.X
00132 #else
00133 #    define _DEPRECATED __attribute__ ((deprecated))
00134 #    define _DEPRECATED_TYPEDEF(type, deprecated_type) typedef type deprecated_type _DEPRECATED
00135 #    define stdext __gnu_cxx
00136 #  if  (__GNUC_MINOR__ < 4 && __GNUC__ < 4)
00137 #    include <ext/stl_hash_fun.h>
00138 #  elif (__GNUC_MINOR__ < 3)
00139 #    include <ext/hash_fun.h>
00140 #  endif
00141 #endif
00142 
00143 //WIN32 specific defines: dllimport and dllexport stuff
00144 #ifdef _WIN32
00145 #  ifdef DLL_TULIP
00146 #    define TLP_SCOPE       __declspec(dllexport)
00147 #  else
00148 #    define TLP_SCOPE       __declspec(dllimport)
00149 #  endif
00150 #endif
00151 #ifndef TLP_SCOPE
00152 #  define TLP_SCOPE
00153 #endif
00154 
00155 #ifdef _WIN32
00156 #  ifdef DLL_TULIP_GL
00157 #    define TLP_GL_SCOPE       __declspec(dllexport)
00158 #  else
00159 #    define TLP_GL_SCOPE       __declspec(dllimport)
00160 #  endif
00161 #endif
00162 #ifndef TLP_GL_SCOPE
00163 #  define TLP_GL_SCOPE
00164 #endif
00165 
00166 #ifdef _WIN32
00167 #  ifdef DLL_TULIP_QT
00168 #    define TLP_QT_SCOPE       __declspec(dllexport)
00169 #  else
00170 #    define TLP_QT_SCOPE       __declspec(dllimport)
00171 #  endif
00172 #endif
00173 #ifndef TLP_QT_SCOPE
00174 #  define TLP_QT_SCOPE
00175 #endif
00176 
00177 #ifdef _WIN32
00178 #  ifdef DLL_TULIP_PYTHON
00179 #    define TLP_PYTHON_SCOPE       __declspec(dllexport)
00180 #  else
00181 #    define TLP_PYTHON_SCOPE       __declspec(dllimport)
00182 #  endif
00183 #endif
00184 #ifndef TLP_PYTHON_SCOPE
00185 #  define TLP_PYTHON_SCOPE
00186 #endif
00187 
00188 #ifdef _WIN32
00189 #  ifdef DLL_TULIP_OGDF
00190 #    define TLP_OGDF_SCOPE         __declspec(dllexport)
00191 #  else
00192 #    define TLP_OGDF_SCOPE         __declspec(dllimport)
00193 #  endif
00194 #endif
00195 #ifndef TLP_OGDF_SCOPE
00196 #  define TLP_OGDF_SCOPE
00197 #endif
00198 
00199 #include <ostream>
00200 
00201 namespace tlp {
00202 /**
00203  *
00204  * @brief return the ostream used for the output of debug messages
00205  */
00206 extern TLP_SCOPE std::ostream& debug();
00207 /**
00208  *
00209  * @brief set the ostream used for the output debug messages
00210  */
00211 extern TLP_SCOPE void setDebugOutput(std::ostream& os);
00212 /**
00213  *
00214  * @brief return the ostream used for the output of warning messages
00215  */
00216 extern TLP_SCOPE std::ostream& warning();
00217 /**
00218  *
00219  * @brief set the ostream used for the output of warning messages
00220  */
00221 extern TLP_SCOPE void setWarningOutput(std::ostream& os);
00222 /**
00223  *
00224  * @brief return the ostream used for the output of error messages
00225  */
00226 extern TLP_SCOPE std::ostream& error();
00227 /**
00228  *
00229  * @brief set the ostream used for the output of error messages
00230  */
00231 extern TLP_SCOPE void setErrorOutput(std::ostream& os);
00232 }
00233 
00234 #endif //TULIPCONF_H
00235 ///@endcond
 All Classes Files Functions Variables Enumerations Enumerator Properties