vigra - vigra/config.hxx Source File

[ 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 #define VIGRA_NEED_BIN_STREAMS
115
116 #define VIGRA_NO_THREADSAFE_STATIC_INIT // at least up to _MSC_VER <= 1600, probably higher
117
118 // usage:
119 // static int * p = VIGRA_SAFE_STATIC(p, new int(42));
120 //
121 #define VIGRA_SAFE_STATIC(p, v) \
122 0; while(p == 0) ::vigra::detail::safeStaticInit(&p, v)
123
124 namespace vigra { namespace detail {
125 template <class T>
126 inline void safeStaticInit(T ** p, T * v)
127 {
128 if (InterlockedCompareExchangePointer((PVOID *)p, v, 0) != 0)
129 delete v;
130 }
131 }} // namespace vigra::detail
132
133 #ifndef VIGRA_ENABLE_ANNOYING_WARNINGS
134 #pragma warning ( disable: 4244 4267) // implicit integer conversion warnings
135 #endif
136
137 #ifdef VIGRA_DLL
138 #define VIGRA_EXPORT __declspec(dllexport)
139 #elif defined(VIGRA_STATIC_LIB)
140 #define VIGRA_EXPORT
141 #else
142 #define VIGRA_EXPORT __declspec(dllimport)
143 #endif
144 #endif // _MSC_VER
145
146 ///////////////////////////////////////////////////////////
147 // //
148 // gcc //
149 // //
150 ///////////////////////////////////////////////////////////
151
152 #if defined(__GNUC__)
153 #if __GNUC__ < 2 || ((__GNUC__ == 2) && (__GNUC_MINOR__ <= 8))
154 #error "Need at least g++ 2.95"
155 #endif
156 #if __GNUC__ < 3
157 #define VIGRA_NO_WORKING_STRINGSTREAM
158 #endif
159 #define HAS_HASH_CONTAINERS
160
161 // these warnings produce too many false positives to be useful
162 #pragma GCC diagnostic ignored "-Wshadow"
163
164 #if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
165 #if defined(__APPLE__) && !(defined(__clang_major__) && __clang_major__ > 4)
166 #define VIGRA_NO_UNIQUE_PTR
167 #endif
168 #else
169 #if defined(__APPLE__) && defined(__clang_major__) && __clang_major__ <= 4
170 #define VIGRA_SHARED_PTR_IN_TR1
171 #endif
172 #define VIGRA_NO_UNIQUE_PTR
173 #endif
174
175
176 #endif // __GNUC__
177
178 ///////////////////////////////////////////////////////////
179 // //
180 // MingW //
181 // //
182 ///////////////////////////////////////////////////////////
183
184 #if defined(__MINGW32__)
185 #define VIGRA_NEED_BIN_STREAMS
186
187 #ifdef VIGRA_DLL
188 #define VIGRA_EXPORT __declspec(dllexport)
189 #elif defined(VIGRA_STATIC_LIB)
190 #define VIGRA_EXPORT
191 #else
192 #define VIGRA_EXPORT __declspec(dllimport)
193 #endif
194 #endif // __MINGW32__
195
196 ///////////////////////////////////////////////////////////
197 // //
198 // SGI C++ 7.2 //
199 // //
200 ///////////////////////////////////////////////////////////
201
202 #if defined(__sgi) && !defined(__GNUC__)
203 #if _COMPILER_VERSION < 720
204 #error "Need SGI C++ 7.2 or later"
205 #endif
206 #if (_COMPILER_VERSION == 720) || (_COMPILER_VERSION == 721)
207 #define SPECIAL_STDEXCEPTION_DEFINITION_NEEDED
208
209 namespace vigra {
210 typedef std::exception StdException; // must be above next #define !!
211 }
212 #define std
213 #define NO_NAMESPACE_STD
214 #endif // _COMPILER_VERSION
215 #define HAS_HASH_CONTAINERS
216 #endif // __sgi
217
218 ///////////////////////////////////////////////////////////
219 // //
220 // Sun C++ ??? //
221 // //
222 ///////////////////////////////////////////////////////////
223
224 #if defined(__sun) && !defined(__GNUC__)
225 #define VIGRA_HAS_ERF
226 #endif // __sun
227
228 ///////////////////////////////////////////////////////////
229 // //
230 // general //
231 // //
232 ///////////////////////////////////////////////////////////
233
234 #ifdef CMATH_NOT_IN_STD
235 #define VIGRA_CSTD
236 #else
237 #define VIGRA_CSTD std
238 #endif
239
240 #ifdef NO_TYPENAME
241 #define typename
242 #endif
243
244 #ifdef NO_EXPLICIT
245 #define explicit
246 #endif
247
248 #ifndef VIGRA_EXPORT
249 #define VIGRA_EXPORT
250 #endif
251
252 #ifdef VIGRA_NO_UNIQUE_PTR
253 # define VIGRA_UNIQUE_PTR std::auto_ptr
254 #else
255 # ifdef _GLIBCXX_INCLUDE_AS_TR1
256 # define VIGRA_UNIQUE_PTR std::tr1::unique_ptr
257 # else
258 # define VIGRA_UNIQUE_PTR std::unique_ptr
259 # endif
260 #endif
261
262 #ifdef VIGRA_SHARED_PTR_IN_TR1
263 # define VIGRA_SHARED_PTR std::tr1::shared_ptr
264 #else
265 # define VIGRA_SHARED_PTR std::shared_ptr
266 #endif
267
268 #ifndef VIGRA_NO_THREADSAFE_STATIC_INIT
269 // usage:
270 // static int * p = VIGRA_SAFE_STATIC(p, new int(42));
271 //
272 #define VIGRA_SAFE_STATIC(p, v) v
273 #endif
274
275 namespace vigra {
276
277 #ifndef SPECIAL_STDEXCEPTION_DEFINITION_NEEDED
278 typedef std::exception StdException;
279 #endif
280
281 } // namespace vigra
282
283 #ifdef DOXYGEN
284 # define doxygen_overloaded_function(fun) fun(...);
285 #else
286 # define doxygen_overloaded_function(fun)
287 #endif
288
289
290 #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.10.0 (Thu Jan 8 2015)