[ 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 #if defined(__APPLE__)
170 #define VIGRA_NO_UNIQUE_PTR
171 #endif
172 #else
173 // C++98 mode. No native unique_ptr support
174 #define VIGRA_NO_UNIQUE_PTR
175 #define VIGRA_SHARED_PTR_IN_TR1
176 #endif
177 #endif // __GNUC__
178
179 ///////////////////////////////////////////////////////////
180 // //
181 // clang //
182 // //
183 ///////////////////////////////////////////////////////////
184 #if defined(__clang__)
185 // In Apple builds of clang, __clang_major__ and __clang_minor__
186 // have totally different values than in other builds of clang.
187 #if defined(__apple_build_version__)
188 // (For Apple builds of clang, __clang_major__ tracks the XCode version.)
189 // For Apple builds, C++11 only works well with libc++, not stdlibc++
190 #define VIGRA_NO_UNIQUE_PTR
191 #if __cplusplus >= 201103L
192 // Must have at least XCode 4 and use libc++ to use std::shared_ptr, etc.
193 // Otherwise, use tr1.
194 #if !((__clang_major__ >= 4) && defined(_LIBCPP_VERSION))
195 #define VIGRA_SHARED_PTR_IN_TR1
196 #endif
197 #else
198 // C++98 mode. No native unique_ptr support
199 #define VIGRA_NO_UNIQUE_PTR
200 #if !defined(_LIBCPP_VERSION)
201 #define VIGRA_SHARED_PTR_IN_TR1
202 #endif
203 #endif
204 #else
205 // This is a conservative constraint:
206 // Full C++11 support was achieved in clang-3.3,
207 // but most support was available in 3.1 and 3.2
208 #if __cplusplus >= 201103L
209 #if (__clang_major__ < 3) || ((__clang_major__ == 3) && (__clang_minor__ < 3))
210 #define VIGRA_SHARED_PTR_IN_TR1
211 #define VIGRA_NO_UNIQUE_PTR
212 #endif
213 #else
214 // C++98 mode. No native shared_ptr/unique_ptr support
215 #define VIGRA_NO_UNIQUE_PTR
216 #define VIGRA_SHARED_PTR_IN_TR1
217 #endif
218 #endif
219 #endif // __clang__
220
221 ///////////////////////////////////////////////////////////
222 // //
223 // MingW //
224 // //
225 ///////////////////////////////////////////////////////////
226
227 #if defined(__MINGW32__)
228 #define VIGRA_NEED_BIN_STREAMS
229
230 #ifdef VIGRA_DLL
231 #define VIGRA_EXPORT __declspec(dllexport)
232 #elif defined(VIGRA_STATIC_LIB)
233 #define VIGRA_EXPORT
234 #else
235 #define VIGRA_EXPORT __declspec(dllimport)
236 #endif
237 #endif // __MINGW32__
238
239 ///////////////////////////////////////////////////////////
240 // //
241 // SGI C++ 7.2 //
242 // //
243 ///////////////////////////////////////////////////////////
244
245 #if defined(__sgi) && !defined(__GNUC__)
246 #if _COMPILER_VERSION < 720
247 #error "Need SGI C++ 7.2 or later"
248 #endif
249 #if (_COMPILER_VERSION == 720) || (_COMPILER_VERSION == 721)
250 #define SPECIAL_STDEXCEPTION_DEFINITION_NEEDED
251
252 namespace vigra {
253 typedef std::exception StdException; // must be above next #define !!
254 }
255 #define std
256 #define NO_NAMESPACE_STD
257 #endif // _COMPILER_VERSION
258 #define HAS_HASH_CONTAINERS
259 #endif // __sgi
260
261 ///////////////////////////////////////////////////////////
262 // //
263 // Sun C++ ??? //
264 // //
265 ///////////////////////////////////////////////////////////
266
267 #if defined(__sun) && !defined(__GNUC__)
268 #define VIGRA_HAS_ERF
269 #endif // __sun
270
271 ///////////////////////////////////////////////////////////
272 // //
273 // general //
274 // //
275 ///////////////////////////////////////////////////////////
276
277 #ifdef CMATH_NOT_IN_STD
278 #define VIGRA_CSTD
279 #else
280 #define VIGRA_CSTD std
281 #endif
282
283 #ifdef NO_TYPENAME
284 #define typename
285 #endif
286
287 #ifdef NO_EXPLICIT
288 #define explicit
289 #endif
290
291 #ifndef VIGRA_EXPORT
292 #define VIGRA_EXPORT
293 #endif
294
295 #ifdef VIGRA_NO_UNIQUE_PTR
296 # define VIGRA_UNIQUE_PTR std::auto_ptr
297 #else
298 # ifdef _GLIBCXX_INCLUDE_AS_TR1
299 # define VIGRA_UNIQUE_PTR std::tr1::unique_ptr
300 # else
301 # define VIGRA_UNIQUE_PTR std::unique_ptr
302 # endif
303 #endif
304
305 #ifdef VIGRA_SHARED_PTR_IN_TR1
306 # define VIGRA_SHARED_PTR std::tr1::shared_ptr
307 #else
308 # define VIGRA_SHARED_PTR std::shared_ptr
309 #endif
310
311 #ifndef VIGRA_NO_THREADSAFE_STATIC_INIT
312 // usage:
313 // static int * p = VIGRA_SAFE_STATIC(p, new int(42));
314 //
315 #define VIGRA_SAFE_STATIC(p, v) v
316 #endif
317
318 namespace vigra {
319
320 #ifndef SPECIAL_STDEXCEPTION_DEFINITION_NEEDED
321 typedef std::exception StdException;
322 #endif
323
324 } // namespace vigra
325
326 #ifdef DOXYGEN
327 # define doxygen_overloaded_function(fun) fun(...);
328 #else
329 # define doxygen_overloaded_function(fun)
330 #endif
331
332
333 #endif // VIGRA_CONFIG_HXX
vigra::abs
FFTWComplex< R >::NormType abs(const FFTWComplex< R > &a)
absolute value (= magnitude)
Definition: fftw3.hxx:1002

© 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.0 (Fri May 19 2017)