[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]

config.hxx
1/************************************************************************/
2/* */
3/* Copyright 1998-2002 by Ullrich Koethe */
4/* */
5/* This file is part of the VIGRA computer vision library. */
6/* The VIGRA Website is */
7/* http://hci.iwr.uni-heidelberg.de/vigra/ */
8/* Please direct questions, bug reports, and contributions to */
9/* ullrich.koethe@iwr.uni-heidelberg.de or */
10/* vigra@informatik.uni-hamburg.de */
11/* */
12/* Permission is hereby granted, free of charge, to any person */
13/* obtaining a copy of this software and associated documentation */
14/* files (the "Software"), to deal in the Software without */
15/* restriction, including without limitation the rights to use, */
16/* copy, modify, merge, publish, distribute, sublicense, and/or */
17/* sell copies of the Software, and to permit persons to whom the */
18/* Software is furnished to do so, subject to the following */
19/* conditions: */
20/* */
21/* The above copyright notice and this permission notice shall be */
22/* included in all copies or substantial portions of the */
23/* Software. */
24/* */
25/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
26/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
27/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
28/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
29/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
30/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
31/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
32/* OTHER DEALINGS IN THE SOFTWARE. */
33/* */
34/************************************************************************/
35
36
37#ifndef VIGRA_CONFIG_HXX
38#define VIGRA_CONFIG_HXX
39
40#include "config_version.hxx"
41#include <stdexcept>
42
43///////////////////////////////////////////////////////////
44// //
45// VisualC++ //
46// //
47///////////////////////////////////////////////////////////
48
49#ifdef _MSC_VER
50 // make sure that we use vigra/windows.h so that incompatibilities are fixed
51 #include "windows.h"
52
53 #if(_MSC_VER < 1100) // before VisualC++ 5.0
54 #error "Need VisualC++ 5.0, Service Pack 2, or later"
55 #endif // _MSC_VER < 1100
56
57 #if (_MSC_VER < 1300)
58 #define NO_TYPENAME // no 'typename' keyword
59 #define TEMPLATE_COPY_CONSTRUCTOR_BUG
60 #define NO_STL_MEMBER_TEMPLATES
61 #define NO_INLINE_STATIC_CONST_DEFINITION
62 #define CMATH_NOT_IN_STD
63 #define NO_COVARIANT_RETURN_TYPES
64
65 #ifdef VIGRA_NO_STD_MINMAX // activate if necessary
66 namespace std {
67
68 template<class T>
69 const T& min(const T& x, const T& y)
70 {
71 return (y < x)
72 ? y
73 : x;
74 }
75
76 template<class T>
77 const T& max(const T& x, const T& y)
78 {
79 return (x < y)
80 ? y
81 : x;
82 }
83 }
84 #endif // VIGRA_NO_STD_MINMAX
85 #endif // (_MSC_VER < 1300)
86
87 #if _MSC_VER < 1310
88 #pragma warning( disable : 4786 4250 4244 4305)
89
90 #define NO_PARTIAL_TEMPLATE_SPECIALIZATION
91 #define NO_OUT_OF_LINE_MEMBER_TEMPLATES
92 #include <cmath>
93
94 #ifdef _MSC_EXTENSIONS
95 #ifndef CMATH_NOT_IN_STD
96 namespace std {
97 #endif // CMATH_NOT_IN_STD
98 inline double abs(double v) { return fabs(v); }
99 inline float abs(float v) { return fabs(v); }
100 #ifndef CMATH_NOT_IN_STD
101 }
102 #endif // CMATH_NOT_IN_STD
103 #endif // _MSC_EXTENSIONS
104 #endif // _MSC_VER < 1310
105
106 #if _MSC_VER < 1400
107 #define VIGRA_NO_WORKING_STRINGSTREAM
108 #endif
109
110 #if _MSC_VER < 1600
111 #define VIGRA_NO_UNIQUE_PTR
112 #endif
113
114 #if _MSC_VER < 1800
115 #define VIGRA_NO_VARIADIC_TEMPLATES
116 #endif
117
118 #define VIGRA_NEED_BIN_STREAMS
119
120 #define VIGRA_NO_THREADSAFE_STATIC_INIT // at least up to _MSC_VER <= 1600, probably higher
121
122 // usage:
123 // static int * p = VIGRA_SAFE_STATIC(p, new int(42));
124 //
125 #define VIGRA_SAFE_STATIC(p, v) \
126 0; while(p == 0) ::vigra::detail::safeStaticInit(&p, v)
127
128 namespace vigra { namespace detail {
129 template <class T>
130 inline void safeStaticInit(T ** p, T * v)
131 {
132 if (InterlockedCompareExchangePointer((PVOID *)p, v, 0) != 0)
133 delete v;
134 }
135 }} // namespace vigra::detail
136
137 #ifndef VIGRA_ENABLE_ANNOYING_WARNINGS
138 #pragma warning ( disable: 4244 4267) // implicit integer conversion warnings
139 #endif
140
141 #ifdef VIGRA_DLL
142 #define VIGRA_EXPORT __declspec(dllexport)
143 #elif defined(VIGRA_STATIC_LIB)
144 #define VIGRA_EXPORT
145 #else
146 #define VIGRA_EXPORT __declspec(dllimport)
147 #endif
148#endif // _MSC_VER
149
150///////////////////////////////////////////////////////////
151// //
152// gcc //
153// //
154///////////////////////////////////////////////////////////
155
156#if defined(__GNUC__) && !defined(__clang__)
157 #if __GNUC__ < 2 || ((__GNUC__ == 2) && (__GNUC_MINOR__ <= 8))
158 #error "Need at least g++ 2.95"
159 #endif
160 #if __GNUC__ < 3
161 #define VIGRA_NO_WORKING_STRINGSTREAM
162 #endif
163 #define HAS_HASH_CONTAINERS
164
165 // these warnings produce too many false positives to be useful
166 #pragma GCC diagnostic ignored "-Wshadow"
167
168 #if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
169 // see https://gcc.gnu.org/gcc-4.4/changes.html
170 #if __GNUC__ < 4 || ((__GNUC__ == 4) && (__GNUC_MINOR__ <= 3))
171 #define VIGRA_NO_UNIQUE_PTR
172 #endif
173 #else
174 // C++98 mode. No native unique_ptr support
175 #define VIGRA_NO_UNIQUE_PTR
176 #define VIGRA_SHARED_PTR_IN_TR1
177 #endif
178#endif // __GNUC__
179
180///////////////////////////////////////////////////////////
181// //
182// clang //
183// //
184///////////////////////////////////////////////////////////
185#if defined(__clang__)
186 // In Apple builds of clang, __clang_major__ and __clang_minor__
187 // have totally different values than in other builds of clang.
188 #if defined(__apple_build_version__)
189 // (For Apple builds of clang, __clang_major__ tracks the XCode version.)
190 #if __cplusplus >= 201103L
191 // For Apple builds, C++11 only works well with libc++, not stdlibc++
192 #if !defined(_LIBCPP_VERSION)
193 #define VIGRA_NO_UNIQUE_PTR
194 #endif
195 // Must have at least XCode 4 and use libc++ to use std::shared_ptr, etc.
196 // Otherwise, use tr1.
197 #if !((__clang_major__ >= 4) && defined(_LIBCPP_VERSION))
198 #define VIGRA_SHARED_PTR_IN_TR1
199 #endif
200 #else
201 // C++98 mode. No native unique_ptr support
202 #define VIGRA_NO_UNIQUE_PTR
203 #if !defined(_LIBCPP_VERSION)
204 #define VIGRA_SHARED_PTR_IN_TR1
205 #endif
206 #endif
207 #else
208 // This is a conservative constraint:
209 // Full C++11 support was achieved in clang-3.3,
210 // but most support was available in 3.1 and 3.2
211 #if __cplusplus >= 201103L
212 #if (__clang_major__ < 3) || ((__clang_major__ == 3) && (__clang_minor__ < 3))
213 #define VIGRA_SHARED_PTR_IN_TR1
214 #define VIGRA_NO_UNIQUE_PTR
215 #endif
216 #else
217 // C++98 mode. No native shared_ptr/unique_ptr support
218 #define VIGRA_NO_UNIQUE_PTR
219 #define VIGRA_SHARED_PTR_IN_TR1
220 #endif
221 #endif
222#endif // __clang__
223
224///////////////////////////////////////////////////////////
225// //
226// MingW //
227// //
228///////////////////////////////////////////////////////////
229
230#if defined(__MINGW32__)
231 #define VIGRA_NEED_BIN_STREAMS
232
233 #ifdef VIGRA_DLL
234 #define VIGRA_EXPORT __declspec(dllexport)
235 #elif defined(VIGRA_STATIC_LIB)
236 #define VIGRA_EXPORT
237 #else
238 #define VIGRA_EXPORT __declspec(dllimport)
239 #endif
240#endif // __MINGW32__
241
242///////////////////////////////////////////////////////////
243// //
244// SGI C++ 7.2 //
245// //
246///////////////////////////////////////////////////////////
247
248#if defined(__sgi) && !defined(__GNUC__)
249 #if _COMPILER_VERSION < 720
250 #error "Need SGI C++ 7.2 or later"
251 #endif
252 #if (_COMPILER_VERSION == 720) || (_COMPILER_VERSION == 721)
253 #define SPECIAL_STDEXCEPTION_DEFINITION_NEEDED
254
255 namespace vigra {
256 typedef std::exception StdException; // must be above next #define !!
257 }
258 #define std
259 #define NO_NAMESPACE_STD
260 #endif // _COMPILER_VERSION
261 #define HAS_HASH_CONTAINERS
262#endif // __sgi
263
264///////////////////////////////////////////////////////////
265// //
266// Sun C++ ??? //
267// //
268///////////////////////////////////////////////////////////
269
270#if defined(__sun) && !defined(__GNUC__)
271 #define VIGRA_HAS_ERF
272#endif // __sun
273
274///////////////////////////////////////////////////////////
275// //
276// general //
277// //
278///////////////////////////////////////////////////////////
279
280#ifdef CMATH_NOT_IN_STD
281 #define VIGRA_CSTD
282#else
283 #define VIGRA_CSTD std
284#endif
285
286#ifdef NO_TYPENAME
287 #define typename
288#endif
289
290#ifdef NO_EXPLICIT
291 #define explicit
292#endif
293
294#ifndef VIGRA_EXPORT
295 #define VIGRA_EXPORT
296#endif
297
298#ifdef VIGRA_NO_UNIQUE_PTR
299# define VIGRA_UNIQUE_PTR std::auto_ptr
300#else
301# ifdef _GLIBCXX_INCLUDE_AS_TR1
302# define VIGRA_UNIQUE_PTR std::tr1::unique_ptr
303# else
304# define VIGRA_UNIQUE_PTR std::unique_ptr
305# endif
306#endif
307
308#ifdef VIGRA_SHARED_PTR_IN_TR1
309# define VIGRA_SHARED_PTR std::tr1::shared_ptr
310#else
311# define VIGRA_SHARED_PTR std::shared_ptr
312#endif
313
314#ifndef VIGRA_NO_THREADSAFE_STATIC_INIT
315 // usage:
316 // static int * p = VIGRA_SAFE_STATIC(p, new int(42));
317 //
318 #define VIGRA_SAFE_STATIC(p, v) v
319#endif
320
321namespace vigra {
322
323#ifndef SPECIAL_STDEXCEPTION_DEFINITION_NEEDED
324 typedef std::exception StdException;
325#endif
326
327} // namespace vigra
328
329#ifdef DOXYGEN
330# define doxygen_overloaded_function(fun) fun(...);
331#else
332# define doxygen_overloaded_function(fun)
333#endif
334
335
336#endif // VIGRA_CONFIG_HXX

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de)
Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany

html generated using doxygen and Python
vigra 1.11.1